Mega Code Archive

 
Categories / C# / Date Time
 

Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object

using System; class DuraNegaUnaryDemo {     const string dataFmt = "{0,22}{1,22}{2,22}" ;     static void ShowDurationNegate( TimeSpan interval )     {         Console.WriteLine( dataFmt, interval, interval.Duration( ), interval.Negate( ) );     }     static void Main()     {         ShowDurationNegate( new TimeSpan( 1 ) );         ShowDurationNegate( new TimeSpan( -1234567 ) );     }  }