开发者

Adding days to a DateTime in C#

Is it possible to a开发者_如何转开发dd dates in C#?

(DateTime.Today.ToLongDateString() + 10)

I tried this but it doesn't work.


Do you want to add days?

DateTime newDate = DateTime.Today.AddDays(10);

Note that you get a new DateTime back!

MSDN


Use DateTime.Today.AddDays(10) or any of the other AddXXX functions on DateTime.


What is the unit of 10. If it is days; then

var todayPlus10Days = DateTime.Today.AddDays(10);


Use AddDays() method:

DateTime dt = DateTime.Today;
dt = dt.AddDays(10);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜