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);
}
}
|