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