Reputation: 7451
Is it possible to add dates in C#?
(DateTime.Today.ToLongDateString() + 10)
I tried this but it doesn't work.
Upvotes: 5
Views: 2574
Reputation: 3298
Use AddDays() method:
DateTime dt = DateTime.Today;
dt = dt.AddDays(10);
Upvotes: 5
Reputation: 35477
What is the unit of 10. If it is days; then
var todayPlus10Days = DateTime.Today.AddDays(10);
Upvotes: 6
Reputation: 19790
Do you want to add days?
DateTime newDate = DateTime.Today.AddDays(10);
Note that you get a new DateTime back!
Upvotes: 13
Reputation: 24988
Use DateTime.Today.AddDays(10)
or any of the other AddXXX functions on DateTime.
Upvotes: 7