Add two TimeSpan in CSharp

Description

The following code shows how to add two TimeSpan.

Example


//  w  ww . j  av a2 s  .  co m
using System;

public class Example
{
   public static void Main()
   {
      TimeSpan baseTimeSpan = new TimeSpan(1, 12, 15, 16);
      TimeSpan interval = TimeSpan.FromDays(1.5);
      baseTimeSpan.Add(interval);
      
      Console.WriteLine(baseTimeSpan.Ticks);
      
   }
}

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