I have run into a mystery using the AddHours function of the C# DateTime
class. I don't get an error, it just doesn't seem to have any effect.

using System;
using Gtk;

namespace test04
{
        class MainClass
        {       
                public static void Main (string[] args)
                {
                        DateTime dtEnd;
                        double dHrs;                    
                        
                        dtEnd = new DateTime();
                        dtEnd = DateTime.Now;
                        Console.WriteLine(String.Format("{0:dddd, dd-MMM-yyyy - 
HH:mm:ss}",
dtEnd));
                        
                        dHrs = 6;
                        Console.WriteLine(String.Format("{0}", dHrs));
                        
                        dtEnd.AddHours(dHrs);
                        Console.WriteLine(String.Format("{0:dddd, dd-MMM-yyyy - 
HH:mm:ss}",
dtEnd));
                }
        }
}

On my console, I get:

Sunday, 27-Sep-2009 - 10:59:39
6
Sunday, 27-Sep-2009 - 10:59:39

whereas I was expecting the time to change to "16:59:39" after calling the
AddHours() function.

What am I doing wrong? I'm building with MonoDevelop 2.0, under linux
2.6.28.

Thanks,
Ben
-- 
View this message in context: 
http://www.nabble.com/C--DateTime-AddHours-tp25635579p25635579.html
Sent from the Mono - General mailing list archive at Nabble.com.

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to