C# TimeSpan Hours

Description

TimeSpan Hours gets the hours component of the time interval represented by the current TimeSpan structure.

Syntax

TimeSpan.Hours has the following syntax.


public int Hours { get; }

Example

The following example creates several TimeSpan objects and displays the Hours property of each.


using System;//  w w  w .  j  av  a2  s  .c om

class TimeSpanPropertiesDemo
{
    static void Main( )
    {
        TimeSpan ts = new TimeSpan( 98712345678 );
        Console.WriteLine(ts.Hours);
    } 
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version