Click or drag to resize
TimeSpan Structure
Represents a time interval.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
[SerializableAttribute]
public struct TimeSpan : IComparable, IComparable<TimeSpan>, 
	IEquatable<TimeSpan>, IFormattable

The TimeSpan type exposes the following members.

Methods
  NameDescription
Public methodEquals(Object)
Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(TimeSpan)
Returns a value indicating whether this instance is equal to a specified TimeSpan object.
Public methodStatic memberEquals(TimeSpan, TimeSpan)
Returns a value that indicates whether two specified instances of TimeSpan are equal.
Public methodStatic memberFromDays
Returns a TimeSpan that represents a specified number of days, where the specification is accurate to the nearest millisecond.
Public methodStatic memberFromHours
Returns a TimeSpan that represents a specified number of hours, where the specification is accurate to the nearest millisecond.
Public methodStatic memberFromMilliseconds
Returns a TimeSpan that represents a specified number of milliseconds.
Public methodStatic memberFromMinutes
Returns a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.
Public methodStatic memberFromSeconds
Returns a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.
Public methodStatic memberFromTicks
Returns a TimeSpan that represents a specified time, where the specification is in units of ticks.
Public methodGetHashCode
Returns a hash code for this instance.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberParse(String)
Converts the string representation of a time interval to its TimeSpan equivalent.
Public methodStatic memberParse(String, IFormatProvider)
Converts the string representation of a time interval to its TimeSpan equivalent by using the specified culture-specific format information.
Public methodToString
Converts the value of the current TimeSpan object to its equivalent string representation.
(Overrides ValueTypeToString.)
Public methodToString(String)
Converts the value of the current TimeSpan object to its equivalent string representation by using the specified format.
Public methodToString(String, IFormatProvider)
Converts the value of the current TimeSpan object to its equivalent string representation by using the specified format and culture-specific formatting information.
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Adds two specified TimeSpan instances.
Public operatorStatic memberEquality
Indicates whether two TimeSpan instances are equal.
Public operatorStatic memberGreaterThan
Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
Public operatorStatic memberGreaterThanOrEqual
Indicates whether a specified TimeSpan is greater than or equal to another specified TimeSpan.
Public operatorStatic memberInequality
Indicates whether two TimeSpan instances are not equal.
Public operatorStatic memberLessThan
Indicates whether a specified TimeSpan is less than another specified TimeSpan.
Public operatorStatic memberLessThanOrEqual
Indicates whether a specified TimeSpan is less than or equal to another specified TimeSpan.
Public operatorStatic memberSubtraction
Subtracts a specified TimeSpan from another specified TimeSpan.
Public operatorStatic memberUnaryNegation
Returns a TimeSpan whose value is the negated value of the specified instance.
Top
Fields
  NameDescription
Public fieldStatic memberMaxValue
Represents the maximum TimeSpan value. This field is read-only.
Public fieldStatic memberMinValue
Represents the minimum TimeSpan value. This field is read-only.
Public fieldStatic memberTicksPerDay
Represents the number of ticks in 1 day. This field is constant.
Public fieldStatic memberTicksPerHour
Represents the number of ticks in 1 hour. This field is constant.
Public fieldStatic memberTicksPerMillisecond
Represents the number of ticks in 1 millisecond. This field is constant.
Public fieldStatic memberTicksPerMinute
Represents the number of ticks in 1 minute. This field is constant.
Public fieldStatic memberTicksPerSecond
Represents the number of ticks in 1 second.
Public fieldStatic memberZero
Represents the zero TimeSpan value. This field is read-only.
Top
Properties
  NameDescription
Public propertyDays
Gets the days component of the time interval represented by the current TimeSpan structure.
Public propertyHours
Gets the hours component of the time interval represented by the current TimeSpan structure.
Public propertyMilliseconds
Gets the milliseconds component of the time interval represented by the current TimeSpan structure.
Public propertyMinutes
Gets the minutes component of the time interval represented by the current TimeSpan structure.
Public propertySeconds
Gets the seconds component of the time interval represented by the current TimeSpan structure.
Public propertyTicks
Gets the number of ticks that represent the value of the current TimeSpan structure.
Public propertyTotalDays
Gets the value of the current TimeSpan structure expressed in whole and fractional days.
Public propertyTotalHours
Gets the value of the current TimeSpan structure expressed in whole and fractional hours.
Public propertyTotalMilliseconds
Gets the value of the current TimeSpan structure expressed in whole and fractional milliseconds.
Public propertyTotalMinutes
Gets the value of the current TimeSpan structure expressed in whole and fractional minutes.
Public propertyTotalSeconds
Gets the value of the current TimeSpan structure expressed in whole and fractional seconds.
Top
See Also