TimeSpan 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
TimeSpan 구조체의 새 인스턴스를 초기화합니다.
오버로드
TimeSpan(Int64) |
TimeSpan 구조체의 새 인스턴스를 지정된 틱 수로 초기화합니다. |
TimeSpan(Int32, Int32, Int32) |
TimeSpan 구조체의 새 인스턴스를 지정된 시간, 분, 초의 수로 초기화합니다. |
TimeSpan(Int32, Int32, Int32, Int32) |
TimeSpan 구조체의 새 인스턴스를 지정된 일, 시간, 분, 초의 수로 초기화합니다. |
TimeSpan(Int32, Int32, Int32, Int32, Int32) |
TimeSpan 구조체의 새 인스턴스를 지정된 일, 시간, 분, 초, 밀리초의 수로 초기화합니다. |
TimeSpan(Int32, Int32, Int32, Int32, Int32, Int32) |
구조체의 TimeSpan 새 instance 지정된 일 수, 시간, 분, 초, 밀리초 및 마이크로초로 초기화합니다. |
TimeSpan(Int64)
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
TimeSpan 구조체의 새 인스턴스를 지정된 틱 수로 초기화합니다.
public:
TimeSpan(long ticks);
public TimeSpan (long ticks);
new TimeSpan : int64 -> TimeSpan
Public Sub New (ticks As Long)
매개 변수
- ticks
- Int64
100나노초 단위로 나타낸 기간입니다.
예제
다음 예제에서는 지정된 수의 틱으로 를 초기화하는 TimeSpan 생성자 오버로드를 사용하여 여러 TimeSpan 개체를 만듭니다.
// 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
*/
// Example of the TimeSpan( long ) constructor.
using System;
class TimeSpanCtorLDemo
{
// Create a TimeSpan object and display its value.
static void CreateTimeSpan( long ticks )
{
TimeSpan elapsedTime = new 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 += " ";
// Display the constructor and its value.
Console.WriteLine( "{0,-33}{1,24}", ctor, elapsedStr );
}
static void Main( )
{
Console.WriteLine(
"This example of the TimeSpan( long ) 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( long ) 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
*/
// Example of the TimeSpan( long ) constructor.
open System
// Create a TimeSpan object and display its value.
let createTimeSpan ticks =
let elapsedTime = TimeSpan ticks
// Format the constructor for display.
let ctor = $"TimeSpan( {ticks} )"
// Pad the end of a TimeSpan string with spaces if
// it does not contain milliseconds.
let elapsedStr = string elapsedTime
let pointIndex = elapsedStr.IndexOf ':'
let pointIndex = elapsedStr.IndexOf('.', pointIndex)
let elapsedStr =
if pointIndex < 0 then elapsedStr + " "
else elapsedStr
// Display the constructor and its value.
printfn $"{ctor,-33}{elapsedStr,24}"
Console.WriteLine(
"This example of the TimeSpan( long ) constructor " +
"\ngenerates the following output.\n" )
Console.WriteLine( "{0,-33}{1,16}", "Constructor", "Value" )
Console.WriteLine( "{0,-33}{1,16}", "-----------", "-----" )
createTimeSpan 1L
createTimeSpan 999999L
createTimeSpan -1000000000000L
createTimeSpan 18012202000000L
createTimeSpan 999999999999999999L
createTimeSpan 1000000000000000000L
(*
This example of the TimeSpan( long ) 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
*)
' Example of the TimeSpan( Long ) constructor.
Module TimeSpanCtorLDemo
' Create a TimeSpan object and display its value.
Sub CreateTimeSpan( ticks As Long )
Dim elapsedTime As New TimeSpan( ticks )
' Format the constructor for display.
Dim ctor AS String = _
String.Format( "TimeSpan( {0} )", ticks )
' Pad the end of a TimeSpan string with spaces if
' it does not contain milliseconds.
Dim elapsedStr As String = elapsedTime.ToString( )
Dim pointIndex As Integer = elapsedStr.IndexOf( ":"c )
pointIndex = elapsedStr.IndexOf( "."c, pointIndex )
If pointIndex < 0 Then elapsedStr &= " "
' Display the constructor and its value.
Console.WriteLine( "{0,-33}{1,24}", ctor, elapsedStr )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of the TimeSpan( Long ) constructor " & _
vbCrLf & "generates the following output." & vbCrLf )
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 )
End Sub
End Module
' This example of the TimeSpan( Long ) 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
설명
틱 하나는 100나노초 또는 1/1000만 초를 나타냅니다. 밀리초 안에 10,000개의 틱이 있습니다.
추가 정보
적용 대상
TimeSpan(Int32, Int32, Int32)
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
TimeSpan 구조체의 새 인스턴스를 지정된 시간, 분, 초의 수로 초기화합니다.
public:
TimeSpan(int hours, int minutes, int seconds);
public TimeSpan (int hours, int minutes, int seconds);
new TimeSpan : int * int * int -> TimeSpan
Public Sub New (hours As Integer, minutes As Integer, seconds As Integer)
매개 변수
- hours
- Int32
시간의 수입니다.
- minutes
- Int32
분의 수입니다.
- seconds
- Int32
시간(초)입니다.
예외
매개 변수는 TimeSpan.MinValue보다 작거나 TimeSpan.MaxValue보다 큰 값을 지정 TimeSpan 합니다.
예제
다음 예제에서는 지정된 시간, 분 및 초로 를 초기화하는 TimeSpan 생성자 오버로드를 사용하여 여러 TimeSpan 개체를 만듭니다.
// Example of the TimeSpan( int, int, int ) constructor.
using namespace System;
// Create a TimeSpan object and display its value.
static void CreateTimeSpan( int hours, int minutes, int seconds )
{
TimeSpan elapsedTime = TimeSpan(hours,minutes,seconds);
// Format the constructor for display.
String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2} )", hours, minutes, seconds );
// Display the constructor and its value.
Console::WriteLine( "{0,-37}{1,16}", ctor, elapsedTime.ToString() );
}
int main()
{
Console::WriteLine( "This example of the TimeSpan( int, int, int ) "
"\nconstructor generates the following output.\n" );
Console::WriteLine( "{0,-37}{1,16}", "Constructor", "Value" );
Console::WriteLine( "{0,-37}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30 );
CreateTimeSpan( -10, 20, 30 );
CreateTimeSpan( 0, 0, 37230 );
CreateTimeSpan( 1000, 2000, 3000 );
CreateTimeSpan( 1000, -2000, -3000 );
CreateTimeSpan( 999999, 999999, 999999 );
}
/*
This example of the TimeSpan( int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30 ) 10:20:30
TimeSpan( -10, 20, 30 ) -09:39:30
TimeSpan( 0, 0, 37230 ) 10:20:30
TimeSpan( 1000, 2000, 3000 ) 43.02:10:00
TimeSpan( 1000, -2000, -3000 ) 40.05:50:00
TimeSpan( 999999, 999999, 999999 ) 42372.15:25:39
*/
// Example of the TimeSpan( int, int, int ) constructor.
using System;
class TimeSpanCtorIIIDemo
{
// Create a TimeSpan object and display its value.
static void CreateTimeSpan( int hours, int minutes,
int seconds )
{
TimeSpan elapsedTime =
new TimeSpan( hours, minutes, seconds );
// Format the constructor for display.
string ctor = String.Format( "TimeSpan( {0}, {1}, {2} )",
hours, minutes, seconds);
// Display the constructor and its value.
Console.WriteLine( "{0,-37}{1,16}",
ctor, elapsedTime.ToString( ) );
}
static void Main( )
{
Console.WriteLine(
"This example of the TimeSpan( int, int, int ) " +
"\nconstructor generates the following output.\n" );
Console.WriteLine( "{0,-37}{1,16}", "Constructor", "Value" );
Console.WriteLine( "{0,-37}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30 );
CreateTimeSpan( -10, 20, 30 );
CreateTimeSpan( 0, 0, 37230 );
CreateTimeSpan( 1000, 2000, 3000 );
CreateTimeSpan( 1000, -2000, -3000 );
CreateTimeSpan( 999999, 999999, 999999 );
}
}
/*
This example of the TimeSpan( int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30 ) 10:20:30
TimeSpan( -10, 20, 30 ) -09:39:30
TimeSpan( 0, 0, 37230 ) 10:20:30
TimeSpan( 1000, 2000, 3000 ) 43.02:10:00
TimeSpan( 1000, -2000, -3000 ) 40.05:50:00
TimeSpan( 999999, 999999, 999999 ) 42372.15:25:39
*/
// Example of the TimeSpan( int, int, int ) constructor.
open System
// Create a TimeSpan object and display its value.
let createTimeSpan hours minutes seconds =
let elapsedTime = TimeSpan(hours, minutes, seconds)
// Format the constructor for display.
let ctor = $"TimeSpan( {hours}, {minutes}, {seconds} )"
// Display the constructor and its value.
printfn $"{ctor,-37}{elapsedTime,16}"
printfn "This example of the TimeSpan( int, int, int ) \nconstructor generates the following output.\n"
printfn "%-37s%16s" "Constructor" "Value"
printfn "%-37s%16s" "-----------" "-----"
createTimeSpan 10 20 30
createTimeSpan -10 20 30
createTimeSpan 0 0 37230
createTimeSpan 1000 2000 3000
createTimeSpan 1000 -2000 -3000
createTimeSpan 999999 999999 999999
(*
This example of the TimeSpan( int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30 ) 10:20:30
TimeSpan( -10, 20, 30 ) -09:39:30
TimeSpan( 0, 0, 37230 ) 10:20:30
TimeSpan( 1000, 2000, 3000 ) 43.02:10:00
TimeSpan( 1000, -2000, -3000 ) 40.05:50:00
TimeSpan( 999999, 999999, 999999 ) 42372.15:25:39
*)
' Example of the TimeSpan( Integer, Integer, Integer ) constructor.
Module TimeSpanCtorIIIDemo
' Create a TimeSpan object and display its value.
Sub CreateTimeSpan( hours As Integer, minutes As Integer, _
seconds As Integer )
Dim elapsedTime As New TimeSpan( hours, minutes, seconds )
' Format the constructor for display.
Dim ctor AS String = _
String.Format( "TimeSpan( {0}, {1}, {2} )", _
hours, minutes, seconds )
' Display the constructor and its value.
Console.WriteLine( "{0,-37}{1,16}", _
ctor, elapsedTime.ToString( ) )
End Sub
Sub Main()
Console.WriteLine( _
"This example of the " & _
"TimeSpan( Integer, Integer, Integer ) " & vbCrLf & _
"constructor generates the following output." & vbCrLf )
Console.WriteLine( "{0,-37}{1,16}", "Constructor", "Value" )
Console.WriteLine( "{0,-37}{1,16}", "-----------", "-----" )
CreateTimeSpan( 10, 20, 30 )
CreateTimeSpan( -10, 20, 30 )
CreateTimeSpan( 0, 0, 37230 )
CreateTimeSpan( 1000, 2000, 3000 )
CreateTimeSpan( 1000, -2000, -3000 )
CreateTimeSpan( 999999, 999999, 999999 )
End Sub
End Module
' This example of the TimeSpan( Integer, Integer, Integer )
' constructor generates the following output.
'
' Constructor Value
' ----------- -----
' TimeSpan( 10, 20, 30 ) 10:20:30
' TimeSpan( -10, 20, 30 ) -09:39:30
' TimeSpan( 0, 0, 37230 ) 10:20:30
' TimeSpan( 1000, 2000, 3000 ) 43.02:10:00
' TimeSpan( 1000, -2000, -3000 ) 40.05:50:00
' TimeSpan( 999999, 999999, 999999 ) 42372.15:25:39
설명
지정된 hours
, minutes
및 seconds
는 틱으로 변환되고 해당 값은 이 instance 초기화합니다.
추가 정보
적용 대상
TimeSpan(Int32, Int32, Int32, Int32)
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
TimeSpan 구조체의 새 인스턴스를 지정된 일, 시간, 분, 초의 수로 초기화합니다.
public:
TimeSpan(int days, int hours, int minutes, int seconds);
public TimeSpan (int days, int hours, int minutes, int seconds);
new TimeSpan : int * int * int * int -> TimeSpan
Public Sub New (days As Integer, hours As Integer, minutes As Integer, seconds As Integer)
매개 변수
- days
- Int32
일 수입니다.
- hours
- Int32
시간의 수입니다.
- minutes
- Int32
분의 수입니다.
- seconds
- Int32
시간(초)입니다.
예외
매개 변수는 TimeSpan.MinValue보다 작거나 TimeSpan.MaxValue보다 큰 값을 지정 TimeSpan 합니다.
예제
다음 예제에서는 지정된 일 수, 시간, 분 및 초로 를 초기화하는 TimeSpan 생성자 오버로드를 사용하여 여러 TimeSpan 개체를 만듭니다.
using namespace System;
// Create a TimeSpan object and display its value.
void CreateTimeSpan( int days, int hours, int minutes, int seconds )
{
TimeSpan elapsedTime = TimeSpan(days,hours,minutes,seconds);
// Format the constructor for display.
array<Object^>^boxedParams = gcnew array<Object^>(4);
boxedParams[ 0 ] = days;
boxedParams[ 1 ] = hours;
boxedParams[ 2 ] = minutes;
boxedParams[ 3 ] = seconds;
String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2}, {3} )", boxedParams );
// Display the constructor and its value.
Console::WriteLine( "{0,-44}{1,16}", ctor, elapsedTime.ToString() );
}
int main()
{
Console::WriteLine( "{0,-44}{1,16}", "Constructor", "Value" );
Console::WriteLine( "{0,-44}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30, 40 );
CreateTimeSpan( -10, 20, 30, 40 );
CreateTimeSpan( 0, 0, 0, 937840 );
CreateTimeSpan( 1000, 2000, 3000, 4000 );
CreateTimeSpan( 1000, -2000, -3000, -4000 );
CreateTimeSpan( 999999, 999999, 999999, 999999 );
}
// The example displays the following output:
// Constructor Value
// ----------- -----
// TimeSpan( 10, 20, 30, 40 ) 10.20:30:40
// TimeSpan( -10, 20, 30, 40 ) -9.03:29:20
// TimeSpan( 0, 0, 0, 937840 ) 10.20:30:40
// TimeSpan( 1000, 2000, 3000, 4000 ) 1085.11:06:40
// TimeSpan( 1000, -2000, -3000, -4000 ) 914.12:53:20
// TimeSpan( 999999, 999999, 999999, 999999 ) 1042371.15:25:39
using System;
class Example
{
// Create a TimeSpan object and display its value.
static void CreateTimeSpan( int days, int hours,
int minutes, int seconds )
{
TimeSpan elapsedTime =
new TimeSpan( days, hours, minutes, seconds );
// Format the constructor for display.
string ctor =
String.Format( "TimeSpan( {0}, {1}, {2}, {3} )",
days, hours, minutes, seconds);
// Display the constructor and its value.
Console.WriteLine( "{0,-44}{1,16}",
ctor, elapsedTime.ToString( ) );
}
static void Main( )
{
Console.WriteLine( "{0,-44}{1,16}", "Constructor", "Value" );
Console.WriteLine( "{0,-44}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30, 40 );
CreateTimeSpan( -10, 20, 30, 40 );
CreateTimeSpan( 0, 0, 0, 937840 );
CreateTimeSpan( 1000, 2000, 3000, 4000 );
CreateTimeSpan( 1000, -2000, -3000, -4000 );
CreateTimeSpan( 999999, 999999, 999999, 999999 );
}
}
// The example displays the following output:
// Constructor Value
// ----------- -----
// TimeSpan( 10, 20, 30, 40 ) 10.20:30:40
// TimeSpan( -10, 20, 30, 40 ) -9.03:29:20
// TimeSpan( 0, 0, 0, 937840 ) 10.20:30:40
// TimeSpan( 1000, 2000, 3000, 4000 ) 1085.11:06:40
// TimeSpan( 1000, -2000, -3000, -4000 ) 914.12:53:20
// TimeSpan( 999999, 999999, 999999, 999999 ) 1042371.15:25:39
open System
// Create a TimeSpan object and display its value.
let createTimeSpan days hours minutes seconds =
let elapsedTime = TimeSpan(days, hours, minutes, seconds)
// Format the constructor for display.
let ctor = $"TimeSpan( {days}, {hours}, {minutes}, {seconds} )"
// Display the constructor and its value.
printfn $"{ctor,-44}{elapsedTime,16}"
printfn "%-44s%16s" "Constructor" "Value"
printfn "%-44s%16s" "-----------" "-----"
createTimeSpan 10 20 30 40
createTimeSpan -10 20 30 40
createTimeSpan 0 0 0 937840
createTimeSpan 1000 2000 3000 4000
createTimeSpan 1000 -2000 -3000 -4000
createTimeSpan 999999 999999 999999 999999
// The example displays the following output:
// Constructor Value
// ----------- -----
// TimeSpan( 10, 20, 30, 40 ) 10.20:30:40
// TimeSpan( -10, 20, 30, 40 ) -9.03:29:20
// TimeSpan( 0, 0, 0, 937840 ) 10.20:30:40
// TimeSpan( 1000, 2000, 3000, 4000 ) 1085.11:06:40
// TimeSpan( 1000, -2000, -3000, -4000 ) 914.12:53:20
// TimeSpan( 999999, 999999, 999999, 999999 ) 1042371.15:25:39
Module Example
' Create a TimeSpan object and display its value.
Sub CreateTimeSpan( days As Integer, hours As Integer, _
minutes As Integer, seconds As Integer )
Dim elapsedTime As New TimeSpan( _
days, hours, minutes, seconds )
' Format the constructor for display.
Dim ctor AS String = _
String.Format( "TimeSpan( {0}, {1}, {2}, {3} )", _
days, hours, minutes, seconds )
' Display the constructor and its value.
Console.WriteLine( "{0,-44}{1,16}", _
ctor, elapsedTime.ToString( ) )
End Sub
Sub Main()
Console.WriteLine( "{0,-44}{1,16}", "Constructor", "Value" )
Console.WriteLine( "{0,-44}{1,16}", "-----------", "-----" )
CreateTimeSpan( 10, 20, 30, 40 )
CreateTimeSpan( -10, 20, 30, 40 )
CreateTimeSpan( 0, 0, 0, 937840 )
CreateTimeSpan( 1000, 2000, 3000, 4000 )
CreateTimeSpan( 1000, -2000, -3000, -4000 )
CreateTimeSpan( 999999, 999999, 999999, 999999 )
End Sub
End Module
' The example generates the following output:
' Constructor Value
' ----------- -----
' TimeSpan( 10, 20, 30, 40 ) 10.20:30:40
' TimeSpan( -10, 20, 30, 40 ) -9.03:29:20
' TimeSpan( 0, 0, 0, 937840 ) 10.20:30:40
' TimeSpan( 1000, 2000, 3000, 4000 ) 1085.11:06:40
' TimeSpan( 1000, -2000, -3000, -4000 ) 914.12:53:20
' TimeSpan( 999999, 999999, 999999, 999999 ) 1042371.15:25:39
설명
지정된 days
, , hours
및 minutes
seconds
는 틱으로 변환되고 해당 값은 이 instance 초기화합니다.
추가 정보
적용 대상
TimeSpan(Int32, Int32, Int32, Int32, Int32)
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
TimeSpan 구조체의 새 인스턴스를 지정된 일, 시간, 분, 초, 밀리초의 수로 초기화합니다.
public:
TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds);
public TimeSpan (int days, int hours, int minutes, int seconds, int milliseconds);
new TimeSpan : int * int * int * int * int -> TimeSpan
Public Sub New (days As Integer, hours As Integer, minutes As Integer, seconds As Integer, milliseconds As Integer)
매개 변수
- days
- Int32
일 수입니다.
- hours
- Int32
시간의 수입니다.
- minutes
- Int32
분의 수입니다.
- seconds
- Int32
시간(초)입니다.
- milliseconds
- Int32
밀리초의 수입니다.
예외
매개 변수는 TimeSpan.MinValue보다 작거나 TimeSpan.MaxValue보다 큰 값을 지정 TimeSpan 합니다.
예제
다음 예제에서는 지정된 일 수, 시간, 분, 초 및 밀리초로 를 초기화하는 TimeSpan 생성자 오버로드를 사용하여 여러 TimeSpan 개체를 만듭니다.
// Example of the TimeSpan( int, int, int, int, int ) constructor.
using namespace System;
// Create a TimeSpan object and display its value.
void CreateTimeSpan( int days, int hours, int minutes, int seconds, int millisec )
{
TimeSpan elapsedTime = TimeSpan(days,hours,minutes,seconds,millisec);
// Format the constructor for display.
array<Object^>^boxedParams = gcnew array<Object^>(5);
boxedParams[ 0 ] = days;
boxedParams[ 1 ] = hours;
boxedParams[ 2 ] = minutes;
boxedParams[ 3 ] = seconds;
boxedParams[ 4 ] = millisec;
String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2}, {3}, {4} )", boxedParams );
// Display the constructor and its value.
Console::WriteLine( "{0,-48}{1,24}", ctor, elapsedTime.ToString() );
}
int main()
{
Console::WriteLine( "This example of the TimeSpan( int, int, int, int, int ) "
"\nconstructor generates the following output.\n" );
Console::WriteLine( "{0,-48}{1,16}", "Constructor", "Value" );
Console::WriteLine( "{0,-48}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30, 40, 50 );
CreateTimeSpan( -10, 20, 30, 40, 50 );
CreateTimeSpan( 0, 0, 0, 0, 937840050 );
CreateTimeSpan( 1111, 2222, 3333, 4444, 5555 );
CreateTimeSpan( 1111, -2222, -3333, -4444, -5555 );
CreateTimeSpan( 99999, 99999, 99999, 99999, 99999 );
}
/*
This example of the TimeSpan( int, int, int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000
TimeSpan( -10, 20, 30, 40, 50 ) -9.03:29:19.9500000
TimeSpan( 0, 0, 0, 0, 937840050 ) 10.20:30:40.0500000
TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000
TimeSpan( 1111, -2222, -3333, -4444, -5555 ) 1016.01:12:50.4450000
TimeSpan( 99999, 99999, 99999, 99999, 99999 ) 104236.05:27:18.9990000
*/
// Example of the TimeSpan( int, int, int, int, int ) constructor.
using System;
class TimeSpanCtorIIIIIDemo
{
// Create a TimeSpan object and display its value.
static void CreateTimeSpan( int days, int hours,
int minutes, int seconds, int millisec )
{
TimeSpan elapsedTime = new TimeSpan(
days, hours, minutes, seconds, millisec );
// Format the constructor for display.
string ctor =
String.Format( "TimeSpan( {0}, {1}, {2}, {3}, {4} )",
days, hours, minutes, seconds, millisec);
// Display the constructor and its value.
Console.WriteLine( "{0,-48}{1,24}",
ctor, elapsedTime.ToString( ) );
}
static void Main( )
{
Console.WriteLine(
"This example of the " +
"TimeSpan( int, int, int, int, int ) " +
"\nconstructor generates the following output.\n" );
Console.WriteLine( "{0,-48}{1,16}", "Constructor", "Value" );
Console.WriteLine( "{0,-48}{1,16}", "-----------", "-----" );
CreateTimeSpan( 10, 20, 30, 40, 50 );
CreateTimeSpan( -10, 20, 30, 40, 50 );
CreateTimeSpan( 0, 0, 0, 0, 937840050 );
CreateTimeSpan( 1111, 2222, 3333, 4444, 5555 );
CreateTimeSpan( 1111, -2222, -3333, -4444, -5555 );
CreateTimeSpan( 99999, 99999, 99999, 99999, 99999 );
}
}
/*
This example of the TimeSpan( int, int, int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000
TimeSpan( -10, 20, 30, 40, 50 ) -9.03:29:19.9500000
TimeSpan( 0, 0, 0, 0, 937840050 ) 10.20:30:40.0500000
TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000
TimeSpan( 1111, -2222, -3333, -4444, -5555 ) 1016.01:12:50.4450000
TimeSpan( 99999, 99999, 99999, 99999, 99999 ) 104236.05:27:18.9990000
*/
// Example of the TimeSpan( int, int, int, int, int ) constructor.
open System
// Create a TimeSpan object and display its value.
let createTimeSpan days hours minutes seconds millisec =
let elapsedTime = TimeSpan(days, hours, minutes, seconds, millisec)
// Format the constructor for display.
let ctor = $"TimeSpan( {days}, {hours}, {minutes}, {seconds}, {millisec} )"
// Display the constructor and its value.
printfn $"{ctor,-48}{elapsedTime,24}"
printfn "This example of the TimeSpan( int, int, int, int, int ) \nconstructor generates the following output.\n"
printfn "%-48s%16s" "Constructor" "Value"
printfn "%-48s%16s" "-----------" "-----"
createTimeSpan 10 20 30 40 50
createTimeSpan -10 20 30 40 50
createTimeSpan 0 0 0 0 937840050
createTimeSpan 1111 2222 3333 4444 5555
createTimeSpan 1111 -2222 -3333 -4444 -5555
createTimeSpan 99999 99999 99999 99999 99999
(*
This example of the TimeSpan( int, int, int, int, int )
constructor generates the following output.
Constructor Value
----------- -----
TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000
TimeSpan( -10, 20, 30, 40, 50 ) -9.03:29:19.9500000
TimeSpan( 0, 0, 0, 0, 937840050 ) 10.20:30:40.0500000
TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000
TimeSpan( 1111, -2222, -3333, -4444, -5555 ) 1016.01:12:50.4450000
TimeSpan( 99999, 99999, 99999, 99999, 99999 ) 104236.05:27:18.9990000
*)
' Example of the
' TimeSpan( Integer, Integer, Integer, Integer, Integer ) constructor.
Module TimeSpanCtorIIIIIDemo
' Create a TimeSpan object and display its value.
Sub CreateTimeSpan( days As Integer, hours As Integer, _
minutes As Integer, seconds As Integer, millisec As Integer )
Dim elapsedTime As New TimeSpan( _
days, hours, minutes, seconds, millisec )
' Format the constructor for display.
Dim ctor As String = _
String.Format( "TimeSpan( {0}, {1}, {2}, {3}, {4} )", _
days, hours, minutes, seconds, millisec )
' Display the constructor and its value.
Console.WriteLine( "{0,-48}{1,24}", _
ctor, elapsedTime.ToString( ) )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of the " & vbCrLf & _
"TimeSpan( Integer, Integer, " & _
"Integer, Integer, Integer ) " & vbCrLf & _
"constructor generates the following output." & vbCrLf )
Console.WriteLine( "{0,-48}{1,16}", "Constructor", "Value" )
Console.WriteLine( "{0,-48}{1,16}", "-----------", "-----" )
CreateTimeSpan( 10, 20, 30, 40, 50 )
CreateTimeSpan( -10, 20, 30, 40, 50 )
CreateTimeSpan( 0, 0, 0, 0, 937840050 )
CreateTimeSpan( 1111, 2222, 3333, 4444, 5555 )
CreateTimeSpan( 1111, -2222, -3333, -4444, -5555 )
CreateTimeSpan( 99999, 99999, 99999, 99999, 99999 )
End Sub
End Module
' This example of the
' TimeSpan( Integer, Integer, Integer, Integer, Integer )
' constructor generates the following output.
'
' Constructor Value
' ----------- -----
' TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000
' TimeSpan( -10, 20, 30, 40, 50 ) -9.03:29:19.9500000
' TimeSpan( 0, 0, 0, 0, 937840050 ) 10.20:30:40.0500000
' TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000
' TimeSpan( 1111, -2222, -3333, -4444, -5555 ) 1016.01:12:50.4450000
' TimeSpan( 99999, 99999, 99999, 99999, 99999 ) 104236.05:27:18.9990000
설명
지정된 days
, , hours
, minutes
및 seconds
milliseconds
는 틱으로 변환되고 해당 값은 이 instance 초기화합니다.
추가 정보
적용 대상
TimeSpan(Int32, Int32, Int32, Int32, Int32, Int32)
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
- Source:
- TimeSpan.cs
구조체의 TimeSpan 새 instance 지정된 일 수, 시간, 분, 초, 밀리초 및 마이크로초로 초기화합니다.
public:
TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds, int microseconds);
public TimeSpan (int days, int hours, int minutes, int seconds, int milliseconds, int microseconds);
new TimeSpan : int * int * int * int * int * int -> TimeSpan
Public Sub New (days As Integer, hours As Integer, minutes As Integer, seconds As Integer, milliseconds As Integer, microseconds As Integer)
매개 변수
- days
- Int32
일 수입니다.
- hours
- Int32
시간의 수입니다.
- minutes
- Int32
분의 수입니다.
- seconds
- Int32
시간(초)입니다.
- milliseconds
- Int32
밀리초의 수입니다.
- microseconds
- Int32
마이크로초 수입니다.
예외
설명
지정된 days
, , hours
, minutes
, seconds
, milliseconds
및 microseconds
는 틱으로 변환되고 해당 값은 이 instance 초기화합니다.
적용 대상
.NET