The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
TimeSpan Constructor (Int64)
.NET Framework (current version)
Initializes a new instance of the TimeSpan structure to the specified number of ticks.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- ticks
-
Type:
System::Int64
A time period expressed in 100-nanosecond units.
A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.
The following example creates several TimeSpan objects using the constructor overload that initializes a TimeSpan to a specified number of ticks.
// Example of the TimeSpan( __int64 ) constructor. using namespace System; // Create a TimeSpan object and display its value. void CreateTimeSpan( __int64 ticks ) { TimeSpan elapsedTime = TimeSpan(ticks); // Format the constructor for display. String^ ctor = String::Format( "TimeSpan( {0} )", ticks ); // Pad the end of a TimeSpan string with spaces if // it does not contain milliseconds. String^ elapsedStr = elapsedTime.ToString(); int pointIndex = elapsedStr->IndexOf( ':' ); pointIndex = elapsedStr->IndexOf( '.', pointIndex ); if ( pointIndex < 0 ) elapsedStr = String::Concat( elapsedStr, " " ); // Display the constructor and its value. Console::WriteLine( "{0,-33}{1,24}", ctor, elapsedStr ); } int main() { Console::WriteLine( "This example of the TimeSpan( __int64 ) constructor " "\ngenerates the following output.\n" ); Console::WriteLine( "{0,-33}{1,16}", "Constructor", "Value" ); Console::WriteLine( "{0,-33}{1,16}", "-----------", "-----" ); CreateTimeSpan( 1 ); CreateTimeSpan( 999999 ); CreateTimeSpan( -1000000000000 ); CreateTimeSpan( 18012202000000 ); CreateTimeSpan( 999999999999999999 ); CreateTimeSpan( 1000000000000000000 ); } /* This example of the TimeSpan( __int64 ) constructor generates the following output. Constructor Value ----------- ----- TimeSpan( 1 ) 00:00:00.0000001 TimeSpan( 999999 ) 00:00:00.0999999 TimeSpan( -1000000000000 ) -1.03:46:40 TimeSpan( 18012202000000 ) 20.20:20:20.2000000 TimeSpan( 999999999999999999 ) 1157407.09:46:39.9999999 TimeSpan( 1000000000000000000 ) 1157407.09:46:40 */
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: