Get the value of TimeSpan expressed in whole and fractional hours in CSharp
Description
The following code shows how to get the value of TimeSpan expressed in whole and fractional hours.
Example
/* w w w. jav a 2 s .com*/
using System;
public class Example
{
public static void Main()
{
// Define an interval of 1 day, 15+ hours.
TimeSpan interval = new TimeSpan(1, 15, 42, 45, 750);
Console.WriteLine("Value of TimeSpan: {0}", interval);
Console.WriteLine("{0:N5} hours, as follows:", interval.TotalHours);
}
}
The code above generates the following result.