[Mono-list] C# DateTime AddHours
Patrick Persson
calahatras at gmail.com
Sun Sep 27 13:31:49 EDT 2009
AddHours gives you a new DateTime instance.
/ patrick
On Sun, Sep 27, 2009 at 19:28, tynman <tyndall at attglobal.net> wrote:
>
> 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 - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090927/bed7690d/attachment.html
More information about the Mono-list
mailing list