WTF: DateTime.AddDays() is not working as expected


Working with following code on DateTime AddDays operation I found end result is not the addition of days!!
int increment = 5;
DateTime now = DateTime.Now; //Current Date
now.AddDays(increment); //Increment by 5 days

Console.WriteLine("Today's date:" + DateTime.Now);
Console.WriteLine("New Date:" + now.ToString());
 
Read More
Comments (2)

  1. Reto says:

    AddDays doesn't modify, it returns a new DateTime

  2. Priyan R says:

    AddDays returns a new DateTime adding the days so u need now=now.AddDays(increment)