Add a specified time interval to a DateTimeOffset in CSharp

Description

The following code shows how to add a specified time interval to a DateTimeOffset.

Example


using System;/* w  w w.  j a  v  a2s . co m*/

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset takeOff = new DateTimeOffset(2014, 6, 1, 7, 55, 0, 
                                 new TimeSpan(-5, 0, 0));
    DateTimeOffset currentTime = takeOff;
    currentTime = currentTime.Add(new TimeSpan(2, 25, 0));
    Console.WriteLine(currentTime);
    
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var