C# TimeSpan Negate

Description

TimeSpan Negate returns a new TimeSpan object whose value is the negated value of this instance.

Syntax

TimeSpan.Negate has the following syntax.


public TimeSpan Negate()

Returns

TimeSpan.Negate method returns A new object with the same numeric value as this instance, but with the opposite sign.

Example

The following example applies the Negate method to TimeSpan object.


/*w  w w  .  ja  va 2 s.  co  m*/
using System;

class DuraNegaUnaryDemo
{
    static void Main()
    {
        TimeSpan ts = new TimeSpan( 1 );
       
        Console.WriteLine( ts.Negate( ) );
    } 
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version