TimeSpan コンストラクタ (Int32, Int32, Int32, Int32, Int32)
新しい TimeSpan を指定した日数、時間数、分数、秒数、ミリ秒数に初期化します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Public Sub New ( _ days As Integer, _ hours As Integer, _ minutes As Integer, _ seconds As Integer, _ milliseconds As Integer _ )
Dim days As Integer Dim hours As Integer Dim minutes As Integer Dim seconds As Integer Dim milliseconds As Integer Dim instance As New TimeSpan(days, hours, minutes, seconds, milliseconds)
public function TimeSpan ( days : int, hours : int, minutes : int, seconds : int, milliseconds : int )
- seconds
秒数。
- milliseconds
ミリ秒数。



次に示すのは、TimeSpan を指定した日数、時間数、分数、秒数、およびミリ秒数に初期化するコンストラクタのオーバーロードを使用して、複数の TimeSpan オブジェクトを作成するコード例です。
' Example of the ' TimeSpan( Integer, Integer, Integer, Integer, Integer ) constructor. Imports System Imports Microsoft.VisualBasic 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
// 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. 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. import 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} )" , new Object[] { (System.Int32)days, (System.Int32)hours , (System.Int32)minutes, (System.Int32)seconds, (System.Int32)millisec }); // Display the constructor and its value. Console.WriteLine("{0,-48}{1,24}", ctor, elapsedTime.ToString()); } //CreateTimeSpan public static void main(String[] args) { 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); } //main } //TimeSpanCtorIIIIIDemo /* 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 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TimeSpan コンストラクタ (Int32, Int32, Int32, Int32)
新しい TimeSpan を指定した日数、時間数、分数、秒数に初期化します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Public Sub New ( _ days As Integer, _ hours As Integer, _ minutes As Integer, _ seconds As Integer _ )
Dim days As Integer Dim hours As Integer Dim minutes As Integer Dim seconds As Integer Dim instance As New TimeSpan(days, hours, minutes, seconds)
- seconds
秒数。



次に示すのは、TimeSpan を指定した日数、時間数、分数、および秒数に初期化するコンストラクタのオーバーロードを使用して、複数の TimeSpan オブジェクトを作成するコード例です。
' Example of the ' TimeSpan( Integer, Integer, Integer, Integer ) constructor. Imports System Imports Microsoft.VisualBasic Module TimeSpanCtorIIIIDemo ' 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( _ "This example of the " & vbCrLf & "TimeSpan( " & _ "Integer, Integer, Integer, Integer ) " & vbCrLf & _ "constructor generates the following output." & vbCrLf ) 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 ' This example of the ' TimeSpan( Integer, Integer, Integer, Integer ) ' constructor 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 ) 992661.08:57:23
// Example of the TimeSpan( int, int, int, int ) constructor. using System; class TimeSpanCtorIIIIDemo { // 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( "This example of the TimeSpan( int, int, int, int ) " + "\nconstructor generates the following output.\n" ); 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 ); } } /* This example of the TimeSpan( int, int, int, int ) constructor 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 ) 992661.08:57:23 */
// Example of the TimeSpan( 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 ) { 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( "This example of the TimeSpan( int, int, int, int ) " "\nconstructor generates the following output.\n" ); 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 ); } /* This example of the TimeSpan( int, int, int, int ) constructor 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 ) 992661.08:57:23 */
// Example of the TimeSpan( int, int, int, int ) constructor. import System.*; class TimeSpanCtorIIIIDemo { // 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} )", new Object[] { (System.Int32)days, (System.Int32)hours , (System.Int32)minutes, (System.Int32)seconds }); // Display the constructor and its value. Console.WriteLine("{0,-44}{1,16}", ctor, elapsedTime.ToString()); } //CreateTimeSpan public static void main(String[] args) { Console.WriteLine(("This example of the TimeSpan(int, int, int, int )" + "\nconstructor generates the following output.\n")); 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); } //main } //TimeSpanCtorIIIIDemo /* This example of the TimeSpan( int, int, int, int ) constructor 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 ) 992661.08:57:23 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TimeSpan コンストラクタ (Int32, Int32, Int32)
新しい TimeSpan を指定した時間数、分数、秒数に初期化します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim hours As Integer Dim minutes As Integer Dim seconds As Integer Dim instance As New TimeSpan(hours, minutes, seconds)
- seconds
秒数。



次に示すのは、TimeSpan を指定した時間数、分数、および秒数に初期化するコンストラクタのオーバーロードを使用して、複数の TimeSpan オブジェクトを作成するコード例です。
' Example of the TimeSpan( Integer, Integer, Integer ) constructor. Imports System Imports Microsoft.VisualBasic 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
// 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. 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. import 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} )", String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); // Display the constructor and its value. Console.WriteLine("{0,-37}{1,16}", ctor, elapsedTime.ToString()); } //CreateTimeSpan public static void main(String[] args) { 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); } //main } //TimeSpanCtorIIIDemo /* 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 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TimeSpan コンストラクタ
新しい TimeSpan を初期化します。
オーバーロードの一覧
名前 | 説明 |
---|---|
TimeSpan (Int64) | 新しい TimeSpan を指定したタイマ刻みの数に初期化します。 |
TimeSpan (Int32, Int32, Int32) | 新しい TimeSpan を指定した時間数、分数、秒数に初期化します。 |
TimeSpan (Int32, Int32, Int32, Int32) | 新しい TimeSpan を指定した日数、時間数、分数、秒数に初期化します。 |
TimeSpan (Int32, Int32, Int32, Int32, Int32) | 新しい TimeSpan を指定した日数、時間数、分数、秒数、ミリ秒数に初期化します。 |

TimeSpan コンストラクタ (Int64)
新しい TimeSpan を指定したタイマ刻みの数に初期化します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文

次に示すのは、TimeSpan を指定したタイマ刻み数に初期化するコンストラクタのオーバーロードを使用して、複数の TimeSpan オブジェクトを作成するコード例です。
' Example of the TimeSpan( Long ) constructor. Imports System Imports Microsoft.VisualBasic 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
// 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( __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. import 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} )", String.valueOf(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); } //CreateTimeSPan public static void main(String[] args) { 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(-1000000000000L); CreateTimeSpan(18012202000000L); CreateTimeSpan(999999999999999999L); CreateTimeSpan(1000000000000000000L); } //main } //TimeSpanCtorLDemo /* 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 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TimeSpan フィールド
TimeSpan プロパティ
TimeSpan メソッド
名前 | 説明 | |
---|---|---|
![]() | Add | 指定した TimeSpan と、このインスタンスを加算します。 |
![]() | Compare | 2 つの TimeSpan 値を比較し、両者の関係を示す整数を返します。 |
![]() | CompareTo | オーバーロードされます。 指定したオブジェクトまたは TimeSpan とこのインスタンスを比較し、これらの相対値を示す値を返します。 |
![]() | Duration | 値が現在の TimeSpan オブジェクトの絶対値である、新しい TimeSpan オブジェクトを返します。 |
![]() | Equals | オーバーロードされます。 オーバーライドされます。 TimeSpan の 2 つのインスタンスが等しいかどうかを示す値を返します。 |
![]() | FromDays | 指定した日数を表す TimeSpan を返します。日数は、ミリ秒単位の精度で指定します。 |
![]() | FromHours | 指定した時間数を表す TimeSpan を返します。時間数は、ミリ秒単位の精度で指定します。 |
![]() | FromMilliseconds | 指定したミリ秒数を表す TimeSpan を返します。 |
![]() | FromMinutes | 指定した分数を表す TimeSpan を返します。分数は、ミリ秒単位の精度で指定します。 |
![]() | FromSeconds | 指定した秒数を表す TimeSpan を返します。秒数は、ミリ秒単位の精度で指定します。 |
![]() | FromTicks | 指定した時間を表す TimeSpan を返します。時間は、タイマ刻み単位で指定します。 |
![]() | GetHashCode | オーバーライドされます。 このインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | Negate | このインスタンスの値とは符号が逆の値を持つ TimeSpan を返します。 |
![]() | op_Addition | 指定した 2 つの TimeSpan インスタンスを加算します。 |
![]() | op_Equality | 2 つの TimeSpan インスタンスが等しいかどうかを示します。 |
![]() | op_GreaterThan | 指定した TimeSpan が、指定したもう 1 つの TimeSpan より大きいかどうかを示します。 |
![]() | op_GreaterThanOrEqual | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 以上かどうかを示します。 |
![]() | op_Inequality | 2 つの TimeSpan インスタンスが等しくないかどうかを示します。 |
![]() | op_LessThan | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 未満かどうかを示します。 |
![]() | op_LessThanOrEqual | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 以下かどうかを示します。 |
![]() | op_Subtraction | 指定したもう 1 つの TimeSpan から、指定した TimeSpan を減算します。 |
![]() | op_UnaryNegation | 指定したインスタンスの値とは符号が逆の値を持つ TimeSpan を返します。 |
![]() | op_UnaryPlus | TimeSpan の指定したインスタンスを返します。 |
![]() | Parse | 文字列で指定した時間間隔から、新しい TimeSpan オブジェクトを作成します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Subtract | このインスタンスから、指定した TimeSpan を減算します。 |
![]() | ToString | オーバーライドされます。 このインスタンスの値の文字列形式を返します。 |
![]() | TryParse | 文字列で指定した時間間隔から、新しい TimeSpan オブジェクトを作成します。各パラメータは、時間間隔と新しい TimeSpan オブジェクトが返される変数を指定します。 |

TimeSpan メンバ
TimeSpan データ型で公開されるメンバを以下の表に示します。




名前 | 説明 | |
---|---|---|
![]() | Add | 指定した TimeSpan と、このインスタンスを加算します。 |
![]() | Compare | 2 つの TimeSpan 値を比較し、両者の関係を示す整数を返します。 |
![]() | CompareTo | オーバーロードされます。 指定したオブジェクトまたは TimeSpan とこのインスタンスを比較し、これらの相対値を示す値を返します。 |
![]() | Duration | 値が現在の TimeSpan オブジェクトの絶対値である、新しい TimeSpan オブジェクトを返します。 |
![]() | Equals | オーバーロードされます。 オーバーライドされます。 TimeSpan の 2 つのインスタンスが等しいかどうかを示す値を返します。 |
![]() | FromDays | 指定した日数を表す TimeSpan を返します。日数は、ミリ秒単位の精度で指定します。 |
![]() | FromHours | 指定した時間数を表す TimeSpan を返します。時間数は、ミリ秒単位の精度で指定します。 |
![]() | FromMilliseconds | 指定したミリ秒数を表す TimeSpan を返します。 |
![]() | FromMinutes | 指定した分数を表す TimeSpan を返します。分数は、ミリ秒単位の精度で指定します。 |
![]() | FromSeconds | 指定した秒数を表す TimeSpan を返します。秒数は、ミリ秒単位の精度で指定します。 |
![]() | FromTicks | 指定した時間を表す TimeSpan を返します。時間は、タイマ刻み単位で指定します。 |
![]() | GetHashCode | オーバーライドされます。 このインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | Negate | このインスタンスの値とは符号が逆の値を持つ TimeSpan を返します。 |
![]() | op_Addition | 指定した 2 つの TimeSpan インスタンスを加算します。 |
![]() | op_Equality | 2 つの TimeSpan インスタンスが等しいかどうかを示します。 |
![]() | op_GreaterThan | 指定した TimeSpan が、指定したもう 1 つの TimeSpan より大きいかどうかを示します。 |
![]() | op_GreaterThanOrEqual | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 以上かどうかを示します。 |
![]() | op_Inequality | 2 つの TimeSpan インスタンスが等しくないかどうかを示します。 |
![]() | op_LessThan | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 未満かどうかを示します。 |
![]() | op_LessThanOrEqual | 指定した TimeSpan が、指定したもう 1 つの TimeSpan 以下かどうかを示します。 |
![]() | op_Subtraction | 指定したもう 1 つの TimeSpan から、指定した TimeSpan を減算します。 |
![]() | op_UnaryNegation | 指定したインスタンスの値とは符号が逆の値を持つ TimeSpan を返します。 |
![]() | op_UnaryPlus | TimeSpan の指定したインスタンスを返します。 |
![]() | Parse | 文字列で指定した時間間隔から、新しい TimeSpan オブジェクトを作成します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Subtract | このインスタンスから、指定した TimeSpan を減算します。 |
![]() | ToString | オーバーライドされます。 このインスタンスの値の文字列形式を返します。 |
![]() | TryParse | 文字列で指定した時間間隔から、新しい TimeSpan オブジェクトを作成します。各パラメータは、時間間隔と新しい TimeSpan オブジェクトが返される変数を指定します。 |

TimeSpan 構造体
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public Structure TimeSpan Implements IComparable, IComparable(Of TimeSpan), _ IEquatable(Of TimeSpan)
[SerializableAttribute] [ComVisibleAttribute(true)] public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>
[SerializableAttribute] [ComVisibleAttribute(true)] public value class TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>

TimeSpan オブジェクトは、時間間隔 (正数または負数の日、時間、分、秒、および秒の端数として計測された時間) を表します。計測に使用する時間の最大単位は日です。月や年など、より大きな時間単位では日数が異なるため、一貫性を保つために、時間間隔は日単位で計測されます。
TimeSpan オブジェクトの値は、表されている時間間隔と等しいタイマ刻みの数です。タイマ刻みは 100 ナノ秒に相当します。TimeSpan オブジェクトの値には、MinValue から MaxValue までの範囲の値を指定できます。
TimeSpan 値は、[-]d.hh:mm:ss.ff で表すことができます。省略可能なマイナス記号は、負の時間間隔を表します。d の部分は日、hh は 24 時間制の時間、mm は分、ss は秒、ff は秒の端数です。つまり、時間間隔は、時刻なしの正または負の日数、時刻付きの日数、または時刻のみで構成されます。たとえば、タイマ刻みの数が 1.0e+13 に初期化された TimeSpan オブジェクトのテキスト形式は、"11.13:46:40"、つまり、11 日 13 時間 46 分 40 秒を表します。
TimeSpan 型は、System.IComparable インターフェイスと System.IComparable インターフェイスを実装します。

複数の TimeSpan オブジェクトを作成し、各オブジェクトのプロパティを表示するコード例を次に示します。
' Example of the TimeSpan class properties. Imports System Imports Microsoft.VisualBasic Module TimeSpanPropertiesDemo Const headerFmt As String = vbCrLf & "{0,-45}" Const dataFmt As String = "{0,-12}{1,8} {2,-18}{3,21}" ' Display the properties of the TimeSpan parameter. Sub ShowTimeSpanProperties( interval as TimeSpan ) Console.WriteLine( "{0,21}", interval ) Console.WriteLine( dataFmt, _ "Days", interval.Days, "TotalDays", interval.TotalDays ) Console.WriteLine( dataFmt, "Hours", interval.Hours, _ "TotalHours", interval.TotalHours ) Console.WriteLine( dataFmt, "Minutes", interval.Minutes, _ "TotalMinutes", interval.TotalMinutes ) Console.WriteLine( dataFmt, "Seconds", interval.Seconds, _ "TotalSeconds", interval.TotalSeconds ) Console.WriteLine( dataFmt, _ "Milliseconds", interval.Milliseconds, _ "TotalMilliseconds", interval.TotalMilliseconds ) Console.WriteLine( dataFmt, _ Nothing, Nothing, "Ticks", interval.Ticks ) End Sub Sub Main( ) Console.WriteLine( _ "This example of the TimeSpan class properties " & _ "generates the " & vbCrLf & "following output. It " & _ "creates several TimeSpan objects and " & vbCrLf & _ "displays the values of the TimeSpan properties for " & _ "each." ) ' Create and display a TimeSpan value of 1 tick. Console.Write( headerFmt, "TimeSpan( 1 )" ) ShowTimeSpanProperties( new TimeSpan( 1 ) ) ' Create a TimeSpan value with a large number of ticks. Console.Write( headerFmt, "TimeSpan( 111222333444555 )" ) ShowTimeSpanProperties( new TimeSpan( 111222333444555 ) ) ' This TimeSpan has all fields specified. Console.Write( headerFmt, "TimeSpan( 10, 20, 30, 40, 50 )" ) ShowTimeSpanProperties( new TimeSpan( 10, 20, 30, 40, 50 ) ) ' This TimeSpan has all fields overflowing. Console.Write( headerFmt, _ "TimeSpan( 1111, 2222, 3333, 4444, 5555 )" ) ShowTimeSpanProperties( _ new TimeSpan( 1111, 2222, 3333, 4444, 5555 ) ) ' This TimeSpan is based on a number of days. Console.Write( headerFmt, "FromDays( 20.84745602 )" ) ShowTimeSpanProperties( TimeSpan.FromDays( 20.84745602 ) ) End Sub End Module ' This example of the TimeSpan class properties generates the ' following output. It creates several TimeSpan objects and ' displays the values of the TimeSpan properties for each. ' ' TimeSpan( 1 ) 00:00:00.0000001 ' Days 0 TotalDays 1.15740740740741E-12 ' Hours 0 TotalHours 2.77777777777778E-11 ' Minutes 0 TotalMinutes 1.66666666666667E-09 ' Seconds 0 TotalSeconds 1E-07 ' Milliseconds 0 TotalMilliseconds 0.0001 ' Ticks 1 ' ' TimeSpan( 111222333444555 ) 128.17:30:33.3444555 ' Days 128 TotalDays 128.729552597865 ' Hours 17 TotalHours 3089.50926234875 ' Minutes 30 TotalMinutes 185370.555740925 ' Seconds 33 TotalSeconds 11122233.3444555 ' Milliseconds 344 TotalMilliseconds 11122233344.4555 ' Ticks 111222333444555 ' ' TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 ' Days 10 TotalDays 10.8546302083333 ' Hours 20 TotalHours 260.511125 ' Minutes 30 TotalMinutes 15630.6675 ' Seconds 40 TotalSeconds 937840.05 ' Milliseconds 50 TotalMilliseconds 937840050 ' Ticks 9378400500000 ' ' TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 ' Days 1205 TotalDays 1205.94941614583 ' Hours 22 TotalHours 28942.7859875 ' Minutes 47 TotalMinutes 1736567.15925 ' Seconds 9 TotalSeconds 104194029.555 ' Milliseconds 555 TotalMilliseconds 104194029555 ' Ticks 1041940295550000 ' ' FromDays( 20.84745602 ) 20.20:20:20.2000000 ' Days 20 TotalDays 20.8474560185185 ' Hours 20 TotalHours 500.338944444444 ' Minutes 20 TotalMinutes 30020.3366666667 ' Seconds 20 TotalSeconds 1801220.2 ' Milliseconds 200 TotalMilliseconds 1801220200 ' Ticks 18012202000000
// Example of the TimeSpan class properties. using System; class TimeSpanPropertiesDemo { const string headerFmt = "\n{0,-45}"; const string dataFmt = "{0,-12}{1,8} {2,-18}{3,21}" ; // Display the properties of the TimeSpan parameter. static void ShowTimeSpanProperties( TimeSpan interval ) { Console.WriteLine( "{0,21}", interval ); Console.WriteLine( dataFmt, "Days", interval.Days, "TotalDays", interval.TotalDays ); Console.WriteLine( dataFmt, "Hours", interval.Hours, "TotalHours", interval.TotalHours ); Console.WriteLine( dataFmt, "Minutes", interval.Minutes, "TotalMinutes", interval.TotalMinutes ); Console.WriteLine( dataFmt, "Seconds", interval.Seconds, "TotalSeconds", interval.TotalSeconds ); Console.WriteLine( dataFmt, "Milliseconds", interval.Milliseconds, "TotalMilliseconds", interval.TotalMilliseconds ); Console.WriteLine( dataFmt, null, null, "Ticks", interval.Ticks ); } static void Main( ) { Console.WriteLine( "This example of the TimeSpan class properties " + "generates the \nfollowing output. It " + "creates several TimeSpan objects and \ndisplays " + "the values of the TimeSpan properties for each." ); // Create and display a TimeSpan value of 1 tick. Console.Write( headerFmt, "TimeSpan( 1 )" ); ShowTimeSpanProperties( new TimeSpan( 1 ) ); // Create a TimeSpan value with a large number of ticks. Console.Write( headerFmt, "TimeSpan( 111222333444555 )" ); ShowTimeSpanProperties( new TimeSpan( 111222333444555 ) ); // This TimeSpan has all fields specified. Console.Write( headerFmt, "TimeSpan( 10, 20, 30, 40, 50 )" ); ShowTimeSpanProperties( new TimeSpan( 10, 20, 30, 40, 50 ) ); // This TimeSpan has all fields overflowing. Console.Write( headerFmt, "TimeSpan( 1111, 2222, 3333, 4444, 5555 )" ); ShowTimeSpanProperties( new TimeSpan( 1111, 2222, 3333, 4444, 5555 ) ); // This TimeSpan is based on a number of days. Console.Write( headerFmt, "FromDays( 20.84745602 )" ); ShowTimeSpanProperties( TimeSpan.FromDays( 20.84745602 ) ); } } /* This example of the TimeSpan class properties generates the following output. It creates several TimeSpan objects and displays the values of the TimeSpan properties for each. TimeSpan( 1 ) 00:00:00.0000001 Days 0 TotalDays 1.15740740740741E-12 Hours 0 TotalHours 2.77777777777778E-11 Minutes 0 TotalMinutes 1.66666666666667E-09 Seconds 0 TotalSeconds 1E-07 Milliseconds 0 TotalMilliseconds 0.0001 Ticks 1 TimeSpan( 111222333444555 ) 128.17:30:33.3444555 Days 128 TotalDays 128.729552597865 Hours 17 TotalHours 3089.50926234875 Minutes 30 TotalMinutes 185370.555740925 Seconds 33 TotalSeconds 11122233.3444555 Milliseconds 344 TotalMilliseconds 11122233344.4555 Ticks 111222333444555 TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 Days 10 TotalDays 10.8546302083333 Hours 20 TotalHours 260.511125 Minutes 30 TotalMinutes 15630.6675 Seconds 40 TotalSeconds 937840.05 Milliseconds 50 TotalMilliseconds 937840050 Ticks 9378400500000 TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 Days 1205 TotalDays 1205.94941614583 Hours 22 TotalHours 28942.7859875 Minutes 47 TotalMinutes 1736567.15925 Seconds 9 TotalSeconds 104194029.555 Milliseconds 555 TotalMilliseconds 104194029555 Ticks 1041940295550000 FromDays( 20.84745602 ) 20.20:20:20.2000000 Days 20 TotalDays 20.8474560185185 Hours 20 TotalHours 500.338944444444 Minutes 20 TotalMinutes 30020.3366666667 Seconds 20 TotalSeconds 1801220.2 Milliseconds 200 TotalMilliseconds 1801220200 Ticks 18012202000000 */
// Example of the TimeSpan class properties. using namespace System; // Display the properties of the TimeSpan parameter. static void ShowTimeSpanProperties( TimeSpan interval ) { Object^ null = nullptr; String^ dataFmt = "{0,-12}{1,8} {2,-18}{3,21}"; Console::WriteLine( "{0,21}", interval ); Console::WriteLine( dataFmt, "Days", interval.Days, "TotalDays", interval.TotalDays ); Console::WriteLine( dataFmt, "Hours", interval.Hours, "TotalHours", interval.TotalHours ); Console::WriteLine( dataFmt, "Minutes", interval.Minutes, "TotalMinutes", interval.TotalMinutes ); Console::WriteLine( dataFmt, "Seconds", interval.Seconds, "TotalSeconds", interval.TotalSeconds ); Console::WriteLine( dataFmt, "Milliseconds", interval.Milliseconds, "TotalMilliseconds", interval.TotalMilliseconds ); Console::WriteLine( dataFmt, null, null, "Ticks", interval.Ticks ); } int main() { String^ headerFmt = "\n{0,-45}"; Console::WriteLine( "This example of the TimeSpan class properties " "generates the \nfollowing output. It " "creates several TimeSpan objects and \ndisplays " "the values of the TimeSpan properties for each." ); // Create and display a TimeSpan value of 1 tick. Console::Write( headerFmt, "TimeSpan( 1 )" ); ShowTimeSpanProperties( TimeSpan(1) ); // Create a TimeSpan value with a large number of ticks. Console::Write( headerFmt, "TimeSpan( 111222333444555 )" ); ShowTimeSpanProperties( TimeSpan(111222333444555) ); // This TimeSpan has all fields specified. Console::Write( headerFmt, "TimeSpan( 10, 20, 30, 40, 50 )" ); ShowTimeSpanProperties( TimeSpan(10,20,30,40,50) ); // This TimeSpan has all fields overflowing. Console::Write( headerFmt, "TimeSpan( 1111, 2222, 3333, 4444, 5555 )" ); ShowTimeSpanProperties( TimeSpan(1111,2222,3333,4444,5555) ); // This TimeSpan is based on a number of days. Console::Write( headerFmt, "FromDays( 20.84745602 )" ); ShowTimeSpanProperties( TimeSpan::FromDays( 20.84745602 ) ); } /* This example of the TimeSpan class properties generates the following output. It creates several TimeSpan objects and displays the values of the TimeSpan properties for each. TimeSpan( 1 ) 00:00:00.0000001 Days 0 TotalDays 1.15740740740741E-12 Hours 0 TotalHours 2.77777777777778E-11 Minutes 0 TotalMinutes 1.66666666666667E-09 Seconds 0 TotalSeconds 1E-07 Milliseconds 0 TotalMilliseconds 0.0001 Ticks 1 TimeSpan( 111222333444555 ) 128.17:30:33.3444555 Days 128 TotalDays 128.729552597865 Hours 17 TotalHours 3089.50926234875 Minutes 30 TotalMinutes 185370.555740925 Seconds 33 TotalSeconds 11122233.3444555 Milliseconds 344 TotalMilliseconds 11122233344.4555 Ticks 111222333444555 TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 Days 10 TotalDays 10.8546302083333 Hours 20 TotalHours 260.511125 Minutes 30 TotalMinutes 15630.6675 Seconds 40 TotalSeconds 937840.05 Milliseconds 50 TotalMilliseconds 937840050 Ticks 9378400500000 TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 Days 1205 TotalDays 1205.94941614583 Hours 22 TotalHours 28942.7859875 Minutes 47 TotalMinutes 1736567.15925 Seconds 9 TotalSeconds 104194029.555 Milliseconds 555 TotalMilliseconds 104194029555 Ticks 1041940295550000 FromDays( 20.84745602 ) 20.20:20:20.2000000 Days 20 TotalDays 20.8474560185185 Hours 20 TotalHours 500.338944444444 Minutes 20 TotalMinutes 30020.3366666667 Seconds 20 TotalSeconds 1801220.2 Milliseconds 200 TotalMilliseconds 1801220200 Ticks 18012202000000 */
// Example of the TimeSpan class properties. import System.*; class TimeSpanPropertiesDemo { private static String headerFmt = "\n{0 ,-45}"; private static String dataFmt = "{0,-12}{1,8} {2,-18}{3,21}"; // Display the properties of the TimeSpan parameter. static void ShowTimeSpanProperties(TimeSpan interval) { Console.WriteLine("{0,21}", interval); Console.WriteLine(dataFmt, new Object[] { "Days" , String.valueOf(interval.get_Days()), "TotalDays", String.valueOf(interval.get_TotalDays()) }); Console.WriteLine(dataFmt, new Object[] { "Hours", String.valueOf(interval.get_Hours()), "TotalHours", String.valueOf(interval.get_TotalHours()) }); Console.WriteLine(dataFmt, new Object[] { "Minutes" , String.valueOf(interval.get_Minutes()), "TotalMinutes", String.valueOf(interval.get_TotalMinutes()) }); Console.WriteLine(dataFmt, new Object[] { "Seconds" , String.valueOf(interval.get_Seconds()), "TotalSeconds", (System.Double)interval.get_TotalSeconds() }); Console.WriteLine(dataFmt, new Object[] { "Milliseconds", String.valueOf(interval.get_Milliseconds()), "TotalMilliseconds" , (System.Double)interval.get_TotalMilliseconds() }); Console.WriteLine(dataFmt, new Object[] { null, null, "Ticks", String.valueOf(interval.get_Ticks()) }); } //ShowTimeSpanProperties public static void main(String[] args) { Console.WriteLine(("This example of the TimeSpan class properties " + "generates the \nfollowing output. It " + "creates several TimeSpan objects and \ndisplays " + "the values of the TimeSpan properties for each.")); // Create and display a TimeSpan value of 1 tick. Console.Write(headerFmt, "TimeSpan( 1 )"); ShowTimeSpanProperties(new TimeSpan(1)); // Create a TimeSpan value with a large number of ticks. Console.Write(headerFmt, "TimeSpan( 111222333444555 )"); ShowTimeSpanProperties(new TimeSpan(111222333444555L)); // This TimeSpan has all fields specified. Console.Write(headerFmt, "TimeSpan( 10, 20, 30, 40, 50 )"); ShowTimeSpanProperties(new TimeSpan(10, 20, 30, 40, 50)); // This TimeSpan has all fields overflowing. Console.Write(headerFmt, "TimeSpan( 1111, 2222, 3333, 4444, 5555 )"); ShowTimeSpanProperties(new TimeSpan(1111, 2222, 3333, 4444, 5555)); // This TimeSpan is based on a number of days. Console.Write(headerFmt, "FromDays( 20.84745602 )"); ShowTimeSpanProperties(TimeSpan.FromDays(20.84745602)); } //main } //TimeSpanPropertiesDemo /* This example of the TimeSpan class properties generates the following output. It creates several TimeSpan objects and displays the values of the TimeSpan properties for each. TimeSpan( 1 ) 00:00:00.0000001 Days 0 TotalDays 1.1574074074074074E-12 Hours 0 TotalHours 2.7777777777777777E-11 Minutes 0 TotalMinutes 1.6666666666666667E-9 Seconds 0 TotalSeconds 1E-07 Milliseconds 0 TotalMilliseconds 0.0001 Ticks 1 TimeSpan( 111222333444555 ) 128.17:30:33.3444555 Days 128 TotalDays 128.7295525978646 Hours 17 TotalHours 3089.50926234875 Minutes 30 TotalMinutes 185370.555740925 Seconds 33 TotalSeconds 11122233.3444555 Milliseconds 344 TotalMilliseconds 11122233344.4555 Ticks 111222333444555 TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 Days 10 TotalDays 10.854630208333333 Hours 20 TotalHours 260.511125 Minutes 30 TotalMinutes 15630.6675 Seconds 40 TotalSeconds 937840.05 Milliseconds 50 TotalMilliseconds 937840050 Ticks 9378400500000 TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 Days 1205 TotalDays 1205.9494161458333 Hours 22 TotalHours 28942.7859875 Minutes 47 TotalMinutes 1736567.15925 Seconds 9 TotalSeconds 104194029.555 Milliseconds 555 TotalMilliseconds 104194029555 Ticks 1041940295550000 FromDays( 20.84745602 ) 20.20:20:20.2000000 Days 20 TotalDays 20.847456018518518 Hours 20 TotalHours 500.33894444444445 Minutes 20 TotalMinutes 30020.336666666666 Seconds 20 TotalSeconds 1801220.2 Milliseconds 200 TotalMilliseconds 1801220200 Ticks 18012202000000 */


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- time spanのページへのリンク