TimeSpan Structure
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Represents a time interval.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Structure TimeSpan
[SerializableAttribute]
public struct TimeSpan
[SerializableAttribute]
public value class TimeSpan
[<Sealed>]
[<SerializableAttribute>]
type TimeSpan = struct end
JScript supports the use of structures, but not the declaration of new ones.
The TimeSpan type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TimeSpan(Int64) | Initializes a new TimeSpan to the specified number of ticks. | |
TimeSpan(Int32, Int32, Int32) | Initializes a new TimeSpan to a specified number of hours, minutes, and seconds. | |
TimeSpan(Int32, Int32, Int32, Int32) | Initializes a new TimeSpan to a specified number of days, hours, minutes, and seconds. | |
TimeSpan(Int32, Int32, Int32, Int32, Int32) | Initializes a new TimeSpan to a specified number of days, hours, minutes, seconds, and milliseconds. |
Top
Properties
Name | Description | |
---|---|---|
Days | Gets the days component of the time interval represented by the current TimeSpan structure. | |
Hours | Gets the hours component of the time interval represented by the current TimeSpan structure. | |
Milliseconds | Gets the milliseconds component of the time interval represented by the current TimeSpan structure. | |
Minutes | Gets the minutes component of the time interval represented by the current TimeSpan structure. | |
Seconds | Gets the seconds component of the time interval represented by the current TimeSpan structure. | |
Ticks | Gets the number of ticks that represent the value of the current TimeSpan structure. |
Top
Methods
Name | Description | |
---|---|---|
Add | Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. | |
Compare | Compares two TimeSpan values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value. | |
CompareTo | Compares this instance to a specified object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the specified object. | |
Duration | Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object. | |
Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueType. . :: . .Equals(Object).) | |
Equals(TimeSpan, TimeSpan) | Returns a value that indicates whether two specified instances of TimeSpan are equal. | |
FromTicks | Returns a TimeSpan that represents a specified time, where the specification is in units of ticks. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Negate | Returns a new TimeSpan object whose value is the negated value of this instance. | |
Subtract | Returns a new TimeSpan object whose value is the difference between the specified TimeSpan object and this instance. | |
ToString | Converts the value of the current TimeSpan object to its equivalent string representation. (Overrides Object. . :: . .ToString() () () ().) |
Top
Operators
Name | Description | |
---|---|---|
Addition | Adds two specified TimeSpan instances. | |
Equality | Indicates whether two TimeSpan instances are equal. | |
GreaterThan | Indicates whether a specified TimeSpan is greater than another specified TimeSpan. | |
GreaterThanOrEqual | Indicates whether a specified TimeSpan is greater than or equal to another specified TimeSpan. | |
Inequality | Indicates whether two TimeSpan instances are not equal. | |
LessThan | Indicates whether a specified TimeSpan is less than another specified TimeSpan. | |
LessThanOrEqual | Indicates whether a specified TimeSpan is less than or equal to another specified TimeSpan. | |
Subtraction | Subtracts a specified TimeSpan from another specified TimeSpan. | |
UnaryNegation | Returns a TimeSpan whose value is the negated value of the specified instance. | |
UnaryPlus | Returns the specified instance of TimeSpan. |
Top
Fields
Name | Description | |
---|---|---|
MaxValue | Represents the maximum TimeSpan value. This field is read-only. | |
MinValue | Represents the minimum TimeSpan value. This field is read-only. | |
TicksPerDay | Represents the number of ticks in 1 day. This field is constant. | |
TicksPerHour | Represents the number of ticks in 1 hour. This field is constant. | |
TicksPerMillisecond | Represents the number of ticks in 1 millisecond. This field is constant. | |
TicksPerMinute | Represents the number of ticks in 1 minute. This field is constant. | |
TicksPerSecond | Represents the number of ticks in 1 second. | |
Zero | Represents the zero TimeSpan value. This field is read-only. |
Top
Remarks
The value of a TimeSpan object is the number of ticks that equal the represented time interval. A tick is equal to 100 nanoseconds, or one ten-millionth of a second. The value of a TimeSpan object can range from TimeSpan..::..MinValue to TimeSpan..::..MaxValue.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.