Costruttore TimeSpan (Int32, Int32, Int32)
.NET Framework 3.0
Inizializza un nuovo TimeSpan su un numero di ore, minuti e secondi specificato.
Spazio dei nomi: System
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
Nell'esempio di codice riportato di seguito vengono creati parecchi oggetti TimeSpan mediante l'overload del costruttore con il quale viene inizializzato un oggetto TimeSpan su un numero specificato di ore, minuti e secondi.
// 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.
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 Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.