System.TimeSpan.FromMilliseconds Method

Returns a TimeSpan that represents a specified number of milliseconds.

Syntax

public static TimeSpan FromMilliseconds (double value)

Parameters

value
A number of milliseconds.

Returns

An object that represents value.

Exceptions

TypeReason
OverflowExceptionThe TimeSpan represented by value is greater than TimeSpan.MaxValue or less than TimeSpan.MinValue.
ArgumentException value is equal to double.NaN.

Remarks

The value parameter is converted to ticks, and that number of ticks is used to initialize the new TimeSpan. Therefore, value will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the double data type, this conversion can generate an OverflowException for values that are near to but still in the range of either TimeSpan.MinValue or TimeSpan.MaxValue. For example, this causes an OverflowException in the following attempt to instantiate a TimeSpan object.

code reference: System.TimeSpan.FromMinutes#4

Requirements

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