get one day after a date in csharp

To get the date which is one day after a given date, we can simply add one day to the date using the AddDays() method. Here's an example:

main.cs
DateTime someDate = DateTime.Now; // or any other date you want
DateTime oneDayAfter = someDate.AddDays(1);
108 chars
3 lines

Alternatively, we can use a TimeSpan object with a value of one day to achieve the same result:

main.cs
DateTime someDate = DateTime.Now; // or any other date you want
TimeSpan oneDay = TimeSpan.FromDays(1);
DateTime oneDayAfter = someDate + oneDay;
146 chars
4 lines

Both of these approaches will give us a DateTime object representing the date which is one day after the original date.

gistlibby LogSnag