System Namespace DateTime Structure
Adds the value of a given TimeSpan to the value of this instance.
[ VB ]
<Serializable>
Public Function Add ( _
ByVal value As TimeSpan _
) As DateTime
[ C# ]
[ Serializable ]
public DateTime Add (
TimeSpan value
);
[ C++ ]
[ Serializable ]
public: DateTime Add (
TimeSpan value
);
[ JScript ]
public Serializable
function Add (
value : TimeSpan
) : DateTime;
- value
- A TimeSpan that contains the interval to add.
A DateTime whose value is the sum of the date and time represented by this instance and the time interval represented by value.
This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.
The below code snippet demonstrates using the Add method. It calculates the day of the week that is 36 days ( 864 hours ) from this moment.
// calculate what day of the week is 36 days from this instant.
System.DateTime today = System.DateTime.Now;
System.TimeSpan duration = new System.TimeSpan ( 36, 0, 0, 0 );
System.DateTime answer = today.Add ( duration );
System.Response.WriteLine ( "{ 0:dddd }", answer );
' calculate what day of the week is 36 days from this instant.
Dim today As System.DateTime
Dim duration As System.TimeSpan
Dim answer As System.DateTime
today = System.DateTime.Now
duration = New System.TimeSpan ( 36, 0, 0, 0 )
answer = today.Add ( duration )
System.Response.WriteLine ( "{ 0:dddd }", answer ) |
|
C# |
VB |
DateTime Members TimeSpan TimeSpan.Add