DateTime.AddDay Related method are not work

I try this simple code

DateTime t1 = DateTime.Now;
            DateTime t = DateTime.Now;

            t.AddDays(20);
            Debug.Print(t1.ToString());
            Debug.Print(t.ToString());

But the Debug.output is the same.

06/01/2011 00:01:32
06/01/2011 00:01:32

I try both in spider and Bee.

If this methods not works how to change the time??

Thanks

AddDays and other DateTime methods return new instance.

try this:



DateTime t1 = DateTime.Now;
            DateTime t = DateTime.Now;
 
            t1 = t.AddDays(20);
            Debug.Print(t1.ToString());
            Debug.Print(t.ToString());


t.AddDays(20) doesn’t add days to t, it returns a new DateTime object

replace this:

t.AddDays(20);

with this:

t = t.AddDays(20);

@ NickP - How is that different from the post above? :wink:

Thank you Architect and NickP.
Ha, so simple answer, I am stupid.
It waste me all day. I should post early.

Thank you.

I am sure We all had moments like that. Sometimes a second pair of eyes is all that is needed. :wink: