DateTime instances are immutable.  Try this:

DateTime dtNowPlus4 = DateTime.Now.AddHours(4);

-----Original Message-----
From: Jeff Roberts [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 9:26 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] DateTime.AddHours does not work !


I am trying to add to the hours of a DateTime object and it does not seam to
work:

DateTime t = Convert.ToDateTime("11/1/2002");
string s = t.ToString();      //this yields a time of 12:00 AM
t.AddHours(4);
s = t.ToString();                     //still yields a time of 12:00 AM

Why doesn't the Hour property change ?

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to