Add TimeSpan to DateTime : Date Time : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Date Time »

 

Add TimeSpan to DateTime








    
 

using System;
using System.Globalization;

class MainClass {
    public static void Main() {
        DateTime dt = new DateTime();
        DateTime dt1 = new DateTime(2001, 12, 31);
        DateTime dt2 = new DateTime(2000, 12, 31, 23, 59, 59);

        TimeSpan year = new TimeSpan(365 * TimeSpan.TicksPerDay);

        for (int i = 0; i < 10; ++i)
            dt += year;

        Console.WriteLine("DT as string: {0}", dt.ToString());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Date Time