Mega Code Archive

 
Categories / C# / Date Time
 

Create a new TimeSpan to a specified number of hours, minutes, and seconds

using System; class MainClass {     static void CreateTimeSpan( int hours, int minutes, int seconds )     {         TimeSpan elapsedTime = new TimeSpan( hours, minutes, seconds );         string ctor = String.Format( "TimeSpan( {0}, {1}, {2} )", hours, minutes, seconds);         Console.WriteLine( "{0,-37}{1,16}", ctor, elapsedTime.ToString( ) );     }     static void Main( )     {         CreateTimeSpan( 10, 20, 30 );     }  }