C# TimeSpan Add
Description
TimeSpan Add
returns a new TimeSpan object whose value
is the sum of the specified TimeSpan object and this instance.
Syntax
TimeSpan.Add
has the following syntax.
public TimeSpan Add(
TimeSpan ts
)
Parameters
TimeSpan.Add
has the following parameters.
ts
- The time interval to add.
Returns
TimeSpan.Add
method returns A new object that represents the value of this instance plus the value of ts.
Example
The following example calls the Add method to add time intervals to a base TimeSpan value.
/*from w w w .j a v a 2 s.c o m*/
using System;
public class Example
{
public static void Main()
{
TimeSpan baseTimeSpan = new TimeSpan(1, 12, 15, 16);
TimeSpan interval = TimeSpan.FromDays(1.5);
Console.WriteLine(baseTimeSpan.Add(interval));
}
}
The code above generates the following result.