Mega Code Archive

 
Categories / C# / Date Time
 

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

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