TimeSpan time1= TimeSpan.FromHours(1); // my attempt to add 2 hours TimeSpan ts = DateTime.Now.TimeOfDay; ts.Add(time1); MessageBox.Show(ts.ToString()); // for showing me its result
你能给些建议么?
所以你应该做:
TimeSpan ts = DateTime.Now.TimeOfDay; var ts2 = ts.Add(time1); MessageBox.Show(ts2.ToString());