本文整理匯總了C#中System.TimeSpan.TotalDays屬性的典型用法代碼示例。如果您正苦於以下問題:C# TimeSpan.TotalDays屬性的具體用法?C# TimeSpan.TotalDays怎麽用?C# TimeSpan.TotalDays使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.TotalDays屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TimeSpan
// Define an interval of 3 days, 16+ hours.
TimeSpan interval = new TimeSpan(3, 16, 42, 45, 750);
Console.WriteLine("Value of TimeSpan: {0}", interval);
Console.WriteLine("{0:N5} days, as follows:", interval.TotalDays);
Console.WriteLine(" Days: {0,3}", interval.Days);
Console.WriteLine(" Hours: {0,3}", interval.Hours);
Console.WriteLine(" Minutes: {0,3}", interval.Minutes);
Console.WriteLine(" Seconds: {0,3}", interval.Seconds);
Console.WriteLine(" Milliseconds: {0,3}", interval.Milliseconds);
輸出:
Value of TimeSpan: 3.16:42:45.7500000 3.69636 days, as follows: Days: 3 Hours: 16 Minutes: 42 Seconds: 45 Milliseconds: 750
示例2: Main
//引入命名空間
using System;
class MainClas
{
public static void Main()
{
long ticks = 300;
TimeSpan myTimeSpan = new TimeSpan(ticks);
Console.WriteLine("myTimeSpan.Days = " + myTimeSpan.Days);
Console.WriteLine("myTimeSpan.Hours = " + myTimeSpan.Hours);
Console.WriteLine("myTimeSpan.Minutes = " + myTimeSpan.Minutes);
Console.WriteLine("myTimeSpan.Seconds = " + myTimeSpan.Seconds);
Console.WriteLine("myTimeSpan.Milliseconds = " + myTimeSpan.Milliseconds);
Console.WriteLine("myTimeSpan.Ticks = " + myTimeSpan.Ticks);
Console.WriteLine("myTimeSpan.TotalDays = " + myTimeSpan.TotalDays);
Console.WriteLine("myTimeSpan.TotalHours = " + myTimeSpan.TotalHours);
Console.WriteLine("myTimeSpan.TotalMinutes = " + myTimeSpan.TotalMinutes);
Console.WriteLine("myTimeSpan.TotalSeconds = " + myTimeSpan.TotalSeconds);
Console.WriteLine("myTimeSpan.TotalMilliseconds = " + myTimeSpan.TotalMilliseconds);
}
}