System.TimeSpan.TotalHours Property

Gets the value of the current TimeSpan structure expressed in whole and fractional hours.

Syntax

public double TotalHours { get; }

Value

A double that specifies the total number of hours represented by the current instance.

Remarks

This property converts the value of this instance from ticks to hours. This number might include whole and fractional hours.

The TimeSpan.TotalHours property represents whole and fractional hours, whereas the TimeSpan.Hours property represents whole hours.

Example

This example demonstrates using the TimeSpan.TotalHours property.

C# Example

using System;
public class TimeSpanTotalUnitsProperties{
   public static void Main() {
      TimeSpan ts = new TimeSpan((Int64)10e12);
      Console.WriteLine(ts.ToString());
      Console.WriteLine("TotalHours: {0}", ts.TotalHours);
   }
}

The output is

11.13:46:40
TotalHours: 277.777777777778

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0