[SerializableAttribute]
public struct Duration : IComparable
<SerializableAttribute>
Public Structure Duration
Implements IComparable
[SerializableAttribute]
public value class Duration : IComparable
[<SealedAttribute>]
[<SerializableAttribute>]
type Duration =
struct
inherit ValueType
interface IComparable
end
Since durations can specify a number of weeks, months, and/or years, additional properties and methods are available to support those options. Methods are also present that can convert an ISO 8601 formatted string to a duration object and back to a string.
Since the definition of a month and year varies, the class allows the specification of the length of time in days for a month and a year. By default, it uses 30 days for a month, and 365 days for a year. To guarantee a consistent definition of a duration, you can limit the maximum units to weeks when converting the duration to a string.
Duration(Int64) | Construct a duration from a number of timer ticks |
Duration(String) | Construct a duration from a string in ISO 8601 duration format |
Duration(TimeSpan) | Construct a duration from a TimeSpan |
Duration(Int32, TimeSpan) | Construct a duration from a number of weeks and a TimeSpan |
Duration(Int32, Int32, TimeSpan) | Construct a duration from a number of months, weeks, and a TimeSpan |
Duration(Int32, Int32, Int32, TimeSpan) | Construct a duration from a number of years, months, weeks, and a TimeSpan |
Days | Gets the number of whole days represented by this instance |
DaysInOneMonth | This property is used to set or get the number of days in one month |
DaysInOneYear | This property is used to set or get the number of days in one year |
Months | Gets the number of whole months represented by this instance |
Ticks | This allows the underlying time span (and thus the duration) to be serialized and deserialized |
TicksPerMonth | This returns the number of timer ticks in one month based on the current setting of DaysInOneMonth. |
TicksPerYear | This returns the number of timer ticks in one year based on the current setting of DaysInOneYear. |
TimeSpan | This allows access to the underlying TimeSpan object |
TotalMonths | Gets the value of this instance expressed in whole and fractional months |
TotalWeeks | Gets the value of this instance expressed in whole and fractional weeks |
TotalYears | Gets the value of this instance expressed in whole and fractional years |
Weeks | Gets the number of whole weeks represented by this instance |
Years | Gets the number of whole years represented by this instance |
Compare | Compares two Duration values and returns an integer that indicates their relationship |
CompareTo | Compares this instance to a specified object and returns an indication of their relative values |
Equals(Object) |
This is overridden to allow proper comparison of Duration objects
(Overrides ValueTypeEquals(Object)) |
Equals(Duration, Duration) | Returns a value indicating whether two specified instances of Duration are equal |
FromMonths | Returns a Duration that represents a specified number of months, where the specification is accurate to the nearest millisecond. |
FromWeeks | Returns a Duration that represents a specified number of weeks, where the specification is accurate to the nearest millisecond. |
FromYears | Returns a Duration that represents a specified number of years, where the specification is accurate to the nearest millisecond. |
GetHashCode |
Get a hash code for the duration object
(Overrides ValueTypeGetHashCode) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
ToDescription | Convert the duration instance to a text description |
ToDescription(DurationMaxUnit) | Convert the duration instance to a text description with the specified maximum unit of time |
ToString |
Convert the duration instance to its ISO 8601 string form
(Overrides ValueTypeToString) |
ToString(DurationMaxUnit) | Convert the duration instance to its ISO 8601 string form with the specified maximum unit of time |
TryParse | Construct a new Duration object from a duration specified in a string. Parameters specify the duration and the variable where the new Duration object is returned. |
Equality(Duration, Duration) | Overload for equal operator |
GreaterThan(Duration, Duration) | Overload for greater than operator |
GreaterThanOrEqual(Duration, Duration) | Overload for greater than or equal operator |
Inequality(Duration, Duration) | Overload for not equal operator |
LessThan(Duration, Duration) | Overload for less than operator |
LessThanOrEqual(Duration, Duration) | Overload for less than or equal operator |
TicksPerWeek | Represents the number of ticks in 1 week. This field is read-only. |
Zero | This represents a zero length duration. This field is read-only. |