C# TimeSpan Duration

Description

TimeSpan Duration returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.

Syntax

TimeSpan.Duration has the following syntax.


public TimeSpan Duration()

Returns

TimeSpan.Duration method returns A new object whose value is the absolute value of the current TimeSpan object.

Example

The following example applies the Duration method to TimeSpan objects.


//  w w w.j  av a 2  s  .  c  o m
using System;

class DuraNegaUnaryDemo
{
    static void Main()
    {
        TimeSpan interval = new TimeSpan( -1234567 );
        Console.WriteLine( interval.Duration( ));
    } 
} 

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