C# TimeSpan UnaryNegation
Description
TimeSpan UnaryNegation
returns a TimeSpan whose value
is the negated value of the specified instance.
Syntax
TimeSpan.UnaryNegation
has the following syntax.
public static TimeSpan operator -(
TimeSpan t
)
Parameters
TimeSpan.UnaryNegation
has the following parameters.
t
- The time interval to be negated.
Returns
TimeSpan.UnaryNegation
method returns An object that has the same numeric value as this instance, but the opposite
sign.
Example
The following example applies the UnaryNegation operator to TimeSpan object.
using System;//from www.j av a 2 s . c o m
class MainClass
{
static void Main( )
{
TimeSpan Left = new TimeSpan( 2, 0, 0 );
Console.WriteLine( -Left);
}
}
The code above generates the following result.