Jon
Wed Jul 05 13:17:00 CDT 2006
madhur <ahuja.madhur@gmail.com> wrote:
> If I create a DateTime instance like this :
> DateTime d=DateTime.Now();
> And then
> d.AddDays(3);
>
> The 3 days doesnt get added to it. But If I do like this :
>
> DateTime d=DateTime.Now.AddDays(4);
>
> The days gets added correctly.
>
> Can anyone explain me the behaviour ??
Whenever something surprising happens, it's best to consult the
documentation. Here's part of what MSDN says about DateTime.AddDays in
the "Remarks" section:
<quote>
This method does not change the value of this DateTime. Instead, a new
DateTime is returned whose value is the result of this operation.
</quote>
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too