本文整理汇总了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