Calculation based on the TimeSpan : TimeSpan : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » TimeSpan »

 

Calculation based on the TimeSpan









    


using System;

class Test
{
    public static void Main()
    {
        // Create a TimeSpan representing 6.5 days.
        TimeSpan timespan1 = new TimeSpan(6, 12, 0, 0);

        // Create a TimeSpan representing 0.5 days.
        TimeSpan timespan2 = new TimeSpan(0, 12, 0, 0);

        TimeSpan oneWeek = timespan1 + timespan2;

        DateTime now = DateTime.Now;

        DateTime past = now - oneWeek;

        // Create a DateTime representing 1 week in the future.
        DateTime future = now + oneWeek;

        // Display the DateTime instances.
        Console.WriteLine("Now   : {0}", now);
        Console.WriteLine("Past  : {0}", past);
        Console.WriteLine("Future: {0}", future);
    }
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» TimeSpan