System.TimeSpan.Duration Method

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

Syntax

public TimeSpan Duration ()

Returns

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

Exceptions

TypeReason
OverflowExceptionThe value of the current instance is TimeSpan.MinValue.

Remarks

Documentation for this section has not yet been entered.

Example

The following example demonstrates the TimeSpan.Duration method.

C# Example

using System;
public class TimeSpanDurationExample {
   public static void Main() {
      TimeSpan ts = new TimeSpan(Int32.MinValue);
      Console.Write("The absolute value of TimeSpan {0} ", ts);
      Console.WriteLine("is {0}", ts.Duration());
   }
}

The output is

The absolute value of TimeSpan -00:03:34.7483648 is 00:03:34.7483648

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0