Adding a TimeSpan to a given DateTime

后端 未结 8 1003
生来不讨喜
生来不讨喜 2020-12-17 08:36

I just want to add 1 day to a DateTime. So I wrote:

 DateTime date = new DateTime(2010, 4, 29, 10, 25, 00);
 TimeSpan t = new TimeSpan(1, 0, 0,          


        
8条回答
  •  伪装坚强ぢ
    2020-12-17 09:04

    date.Add(t);
    

    returns a modified DateTime and does not change the original instance on which you call the Add method on.

提交回复
热议问题