Add a time interval to a DateTimeOffset in CSharp
Description
The following code shows how to add a time interval to a DateTimeOffset.
Example
// ww w. j av a 2 s .com
using System;
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset date1 = new DateTimeOffset(2014, 1, 1, 13, 32, 45,
new TimeSpan(-5, 0, 0));
TimeSpan interval1 = new TimeSpan(2, 3, 30, 0);
TimeSpan interval2 = new TimeSpan(5, 0, 0, 0);
DateTimeOffset date2;
Console.WriteLine(date1);
date2 = date1 + interval1;
Console.WriteLine(date2);
date2 += interval2;
Console.WriteLine(date2);
}
}
The code above generates the following result.