System.TimeSpan.Seconds Property

Gets the seconds component of the time interval represented by the current TimeSpan structure.

Syntax

public int Seconds { get; }

Value

A int between 0 and 59 inclusive, that represents the seconds component of the current instance.
Note: See TimeSpan.ToString for a more detailed description of the seconds component.

Remarks

A TimeSpan value can be represented as [-]d.hh:mm:ss.ff, where the optional minus sign indicates a negative time interval, the d component is days, hh is hours as measured on a 24-hour clock, mm is minutes, ss is seconds, and ff is fractions of a second. The value of the TimeSpan.Seconds property is the seconds component, ss.

The TimeSpan.Seconds property represents whole seconds, whereas the TimeSpan.TotalSeconds property represents whole and fractional seconds.

Example

This example demonstrates using the TimeSpan.Seconds property.

C# Example

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

The output is

11.13:46:40.3456789
Seconds: 40

Requirements

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