Add time interval to DateTime with + in CSharp

Description

The following code shows how to add time interval to DateTime with +.

Example


using System;//from w w  w  .  java 2s  .c  o m
public class MainClass{
  public static void Main(String[] argv){  
    
            System.DateTime dTime = new System.DateTime(1980, 8, 5);

      System.TimeSpan tSpan = new System.TimeSpan(17, 4, 2, 1); 

      System.DateTime result = dTime + tSpan;

            System.Console.WriteLine(result);
  }
}

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