Initializes a new instance of the TimeSpan class to a specified number of days, hours, minutes, and seconds.
[Visual Basic] Overloads Public Sub New( _ ByVal days As Integer, _ ByVal hours As Integer, _ ByVal minutes As Integer, _ ByVal seconds As Integer _ ) [C#] public TimeSpan( int days, int hours, int minutes, int seconds ); [C++] public: TimeSpan( int days, int hours, int minutes, int seconds ); [JScript] public function TimeSpan( days : int, hours : int, minutes : int, seconds : int );
Exception Type | Condition |
---|---|
ArgumentException | If any of the arguments are negative. |
OverflowException | If the computed ticks value is less than MinValue or greater than MaxValue. |
The Ticks s value is computed by converting hours and minutes into seconds, multiplying the total number of seconds by TicksPerSecond, and then adding this to the product of days and TicksPerDay. The equation is:
Ticks = (long)days * TicksPerDay + ((long)hour * 3600 + (long)minute * 60 + (long)second) * TicksPerSecond
TimeSpan Structure | TimeSpan Members | System Namespace | TimeSpan Constructor Overload List | Int64