TimeSpan total properties

In this chapter you will learn:

  1. Get total properties from TimeSpan

Use TimeSpan total properties

Total... properties return values of type double describing the entire time span.

using System;/*java  2s .  c o m*/
using System.Text;
class Sample
{
    public static void Main()
    {
        TimeSpan ts = TimeSpan.FromDays(10) - TimeSpan.FromSeconds(1);


        Console.WriteLine(ts.TotalDays);  
        Console.WriteLine(ts.TotalHours);  
        Console.WriteLine(ts.TotalMinutes);  
        Console.WriteLine(ts.TotalSeconds);  
        Console.WriteLine(ts.TotalMilliseconds);  
    }
}

The output:

Next chapter...

What you will learn in the next chapter:

  1. Access date value from TimeSpan
Home » C# Tutorial » Date, Time, TimeZone
Compare DateTimeOffset
DateTimeOffset creation
Date time Value from DateTimeOffset
Compare DateTime value
DateTime constant value
DateTime constructor
DateTime properties
Create TimeSpan From
TimeSpan
TimeSpan add and subtract
DateTime and TimeSpan
Compare TimeSpan
TimeSpan constant
TimeSpan Constructor
TimeSpan Duration
TimeSpan format
Negate a TimeSpan
TimeSpan operators
Parse string to TimeSpan
TimeSpan to string
TimeSpan total properties
TimeSpan propeties
Daylight saving
Time zone ID
UTC offset with TimeZone
TimeZone converting
TimeZone creation