本文整理匯總了C#中System.TimeSpan.FromMinutes方法的典型用法代碼示例。如果您正苦於以下問題:C# TimeSpan.FromMinutes方法的具體用法?C# TimeSpan.FromMinutes怎麽用?C# TimeSpan.FromMinutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.FromMinutes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GenTimeSpanFromMinutes
// Example of the TimeSpan.FromMinutes( double ) method.
using System;
class FromMinutesDemo
{
static void GenTimeSpanFromMinutes( double minutes )
{
// Create a TimeSpan object and TimeSpan string from
// a number of minutes.
TimeSpan interval = TimeSpan.FromMinutes( minutes );
string timeInterval = interval.ToString( );
// Pad the end of the TimeSpan string with spaces if it
// does not contain milliseconds.
int pIndex = timeInterval.IndexOf( ':' );
pIndex = timeInterval.IndexOf( '.', pIndex );
if( pIndex < 0 ) timeInterval += " ";
Console.WriteLine( "{0,21}{1,26}", minutes, timeInterval );
}
static void Main( )
{
Console.WriteLine(
"This example of TimeSpan.FromMinutes( double )\n" +
"generates the following output.\n" );
Console.WriteLine( "{0,21}{1,18}",
"FromMinutes", "TimeSpan" );
Console.WriteLine( "{0,21}{1,18}",
"-----------", "--------" );
GenTimeSpanFromMinutes( 0.00001 );
GenTimeSpanFromMinutes( 0.00002 );
GenTimeSpanFromMinutes( 0.12345 );
GenTimeSpanFromMinutes( 1234.56789 );
GenTimeSpanFromMinutes( 12345678.98765 );
GenTimeSpanFromMinutes( 0.01666 );
GenTimeSpanFromMinutes( 1 );
GenTimeSpanFromMinutes( 60 );
GenTimeSpanFromMinutes( 1440 );
GenTimeSpanFromMinutes( 30020.33667 );
}
}
輸出:
FromMinutes TimeSpan ----------- -------- 1E-05 00:00:00.0010000 2E-05 00:00:00.0010000 0.12345 00:00:07.4070000 1234.56789 20:34:34.0730000 12345678.98765 8573.09:18:59.2590000 0.01666 00:00:01 1 00:01:00 60 01:00:00 1440 1.00:00:00 30020.33667 20.20:20:20.2000000