struct TimeSpan

in global :: System

Represents a time interval.


public TimeSpan( int hours, int minutes, int seconds )

Initializes a new instance of the structure to a specified number of hours, minutes, and seconds.

  • hours Number of hours.
  • minutes Number of minutes.
  • seconds Number of seconds.

public TimeSpan( int days, int hours, int minutes, int seconds )

Initializes a new instance of the structure to a specified number of days, hours, minutes, and seconds.

  • days Number of days.
  • hours Number of hours.
  • minutes Number of minutes.
  • seconds Number of seconds.

public TimeSpan( int days, int hours, int minutes, int seconds, int milliseconds )

Initializes a new instance of the structure to a specified number of days, hours, minutes, seconds, and milliseconds.

  • days Number of days.
  • hours Number of hours.
  • minutes Number of minutes.
  • seconds Number of seconds.
  • milliseconds Number of milliseconds.

public TimeSpan( long ticks )

Initializes a new instance of the structure to the specified number of ticks.

  • ticks A time period expressed in 100-nanosecond units.

public TimeSpan Add( TimeSpan ts )

Returns a new object whose value is the sum of the specified object and this instance.

  • ts The time interval to add.
  • Returns A new object that represents the value of this instance plus the value of .

public static int Compare( TimeSpan t1, TimeSpan t2 )

Compares two values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns One of the following values. Value Description -1 is shorter than . 0 is equal to . 1 is longer than .

public int CompareTo( object value )

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.

  • value An object to compare, or .
  • Returns One of the following values. Value Description -1 This instance is shorter than . 0 This instance is equal to . 1 This instance is longer than . -or- is .

public int CompareTo( TimeSpan value )

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 object.

  • value An object to compare to this instance.
  • Returns A signed number indicating the relative values of this instance and . Value Description A negative integer This instance is shorter than . Zero This instance is equal to . A positive integer This instance is longer than .

public int Days { get; }

Gets the days component of the time interval represented by the current structure.

  • Returns The day component of this instance. The return value can be positive or negative.

public TimeSpan Divide( double divisor )

No summary.

public double Divide( TimeSpan ts )

No summary.

public bool Equals( object value )

Returns a value indicating whether this instance is equal to a specified object.

  • value An object to compare with this instance.
  • Returns if is a object that represents the same time interval as the current structure; otherwise, .

public bool Equals( TimeSpan obj )

Returns a value indicating whether this instance is equal to a specified object.

  • obj An object to compare with this instance.
  • Returns if represents the same time interval as this instance; otherwise, .

public static bool Equals( TimeSpan t1, TimeSpan t2 )

Returns a value that indicates whether two specified instances of are equal.

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the values of and are equal; otherwise, .

public static TimeSpan FromDays( double value )

Returns a that represents a specified number of days, where the specification is accurate to the nearest millisecond.

  • value A number of days, accurate to the nearest millisecond.
  • Returns An object that represents .

public static TimeSpan FromHours( double value )

Returns a that represents a specified number of hours, where the specification is accurate to the nearest millisecond.

  • value A number of hours accurate to the nearest millisecond.
  • Returns An object that represents .

public static TimeSpan FromMilliseconds( double value )

Returns a that represents a specified number of milliseconds.

  • value A number of milliseconds.
  • Returns An object that represents .

public static TimeSpan FromMinutes( double value )

Returns a that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.

  • value A number of minutes, accurate to the nearest millisecond.
  • Returns An object that represents .

public static TimeSpan FromSeconds( double value )

Returns a that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.

  • value A number of seconds, accurate to the nearest millisecond.
  • Returns An object that represents .

public static TimeSpan FromTicks( long value )

Returns a that represents a specified time, where the specification is in units of ticks.

  • value A number of ticks that represent a time.
  • Returns An object that represents .

public int Hours { get; }

Gets the hours component of the time interval represented by the current structure.

  • Returns The hour component of the current structure. The return value ranges from -23 through 23.

public static TimeSpan MaxValue

Represents the maximum value. This field is read-only.

public int Milliseconds { get; }

Gets the milliseconds component of the time interval represented by the current structure.

  • Returns The millisecond component of the current structure. The return value ranges from -999 through 999.

public int Minutes { get; }

Gets the minutes component of the time interval represented by the current structure.

  • Returns The minute component of the current structure. The return value ranges from -59 through 59.

public static TimeSpan MinValue

Represents the minimum value. This field is read-only.

public TimeSpan Multiply( double factor )

No summary.

public static TimeSpan op_Addition( TimeSpan t1, TimeSpan t2 )

Adds two specified instances.

  • t1 The first time interval to add.
  • t2 The second time interval to add.
  • Returns An object whose value is the sum of the values of and .

public static TimeSpan op_Division( TimeSpan timeSpan, double divisor )

No summary.

public static double op_Division( TimeSpan t1, TimeSpan t2 )

No summary.

public static bool op_Equality( TimeSpan t1, TimeSpan t2 )

Indicates whether two instances are equal.

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the values of and are equal; otherwise, .

public static bool op_GreaterThan( TimeSpan t1, TimeSpan t2 )

Indicates whether a specified is greater than another specified .

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the value of is greater than the value of ; otherwise, .

public static bool op_GreaterThanOrEqual( TimeSpan t1, TimeSpan t2 )

Indicates whether a specified is greater than or equal to another specified .

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the value of is greater than or equal to the value of ; otherwise, .

public static bool op_Inequality( TimeSpan t1, TimeSpan t2 )

Indicates whether two instances are not equal.

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the values of and are not equal; otherwise, .

public static bool op_LessThan( TimeSpan t1, TimeSpan t2 )

Indicates whether a specified is less than another specified .

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the value of is less than the value of ; otherwise, .

public static bool op_LessThanOrEqual( TimeSpan t1, TimeSpan t2 )

Indicates whether a specified is less than or equal to another specified .

  • t1 The first time interval to compare.
  • t2 The second time interval to compare.
  • Returns if the value of is less than or equal to the value of ; otherwise, .

public static TimeSpan op_Multiply( double factor, TimeSpan timeSpan )

No summary.

public static TimeSpan op_Multiply( TimeSpan timeSpan, double factor )

No summary.

public static TimeSpan op_Subtraction( TimeSpan t1, TimeSpan t2 )

Subtracts a specified from another specified .

  • t1 The minuend.
  • t2 The subtrahend.
  • Returns An object whose value is the result of the value of minus the value of .

public static TimeSpan op_UnaryNegation( TimeSpan t )

Returns a whose value is the negated value of the specified instance.

  • t The time interval to be negated.
  • Returns An object that has the same numeric value as this instance, but the opposite sign.

public static TimeSpan op_UnaryPlus( TimeSpan t )

Returns the specified instance of .

  • t The time interval to return.
  • Returns The time interval specified by .

public static TimeSpan Parse( string s )

Converts the string representation of a time interval to its equivalent.

  • s A string that specifies the time interval to convert.
  • Returns A time interval that corresponds to .

public static TimeSpan Parse( string input, IFormatProvider formatProvider )

Converts the string representation of a time interval to its equivalent by using the specified culture-specific format information.

  • input A string that specifies the time interval to convert.
  • formatProvider An object that supplies culture-specific formatting information.
  • Returns A time interval that corresponds to , as specified by .

public static TimeSpan ParseExact( string input, string format, IFormatProvider formatProvider )

Converts the string representation of a time interval to its equivalent by using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly.

  • input A string that specifies the time interval to convert.
  • format A standard or custom format string that defines the required format of .
  • formatProvider An object that provides culture-specific formatting information.
  • Returns A time interval that corresponds to , as specified by and .

public static TimeSpan ParseExact( string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles )

Converts the string representation of a time interval to its equivalent by using the specified format, culture-specific format information, and styles. The format of the string representation must match the specified format exactly.

  • input A string that specifies the time interval to convert.
  • format A standard or custom format string that defines the required format of .
  • formatProvider An object that provides culture-specific formatting information.
  • styles A bitwise combination of enumeration values that defines the style elements that may be present in .
  • Returns A time interval that corresponds to , as specified by , , and .

public static TimeSpan ParseExact( string input, string[] formats, IFormatProvider formatProvider )

Converts the string representation of a time interval to its equivalent by using the specified array of format strings and culture-specific format information. The format of the string representation must match one of the specified formats exactly.

  • input A string that specifies the time interval to convert.
  • formats A array of standard or custom format strings that defines the required format of .
  • formatProvider An object that provides culture-specific formatting information.
  • Returns A time interval that corresponds to , as specified by and .

public static TimeSpan ParseExact( string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles )

Converts the string representation of a time interval to its equivalent by using the specified formats, culture-specific format information, and styles. The format of the string representation must match one of the specified formats exactly.

  • input A string that specifies the time interval to convert.
  • formats A array of standard or custom format strings that define the required format of .
  • formatProvider An object that provides culture-specific formatting information.
  • styles A bitwise combination of enumeration values that defines the style elements that may be present in input.
  • Returns A time interval that corresponds to , as specified by , , and .

public int Seconds { get; }

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

  • Returns The second component of the current structure. The return value ranges from -59 through 59.

public TimeSpan Subtract( TimeSpan ts )

Returns a new object whose value is the difference between the specified object and this instance.

  • ts The time interval to be subtracted.
  • Returns A new time interval whose value is the result of the value of this instance minus the value of .

public long Ticks { get; }

Gets the number of ticks that represent the value of the current structure.

  • Returns The number of ticks contained in this instance.

public static long TicksPerDay

Represents the number of ticks in 1 day. This field is constant.

public static long TicksPerHour

Represents the number of ticks in 1 hour. This field is constant.

public static long TicksPerMillisecond

Represents the number of ticks in 1 millisecond. This field is constant.

public static long TicksPerMinute

Represents the number of ticks in 1 minute. This field is constant.

public static long TicksPerSecond

Represents the number of ticks in 1 second.

public string ToString( string format )

Converts the value of the current object to its equivalent string representation by using the specified format.

  • format A standard or custom format string.
  • Returns The string representation of the current value in the format specified by the parameter.

public string ToString( string format, IFormatProvider formatProvider )

Converts the value of the current object to its equivalent string representation by using the specified format and culture-specific formatting information.

  • format A standard or custom format string.
  • formatProvider An object that supplies culture-specific formatting information.
  • Returns The string representation of the current value, as specified by and .

public double TotalDays { get; }

Gets the value of the current structure expressed in whole and fractional days.

  • Returns The total number of days represented by this instance.

public double TotalHours { get; }

Gets the value of the current structure expressed in whole and fractional hours.

  • Returns The total number of hours represented by this instance.

public double TotalMilliseconds { get; }

Gets the value of the current structure expressed in whole and fractional milliseconds.

  • Returns The total number of milliseconds represented by this instance.

public double TotalMinutes { get; }

Gets the value of the current structure expressed in whole and fractional minutes.

  • Returns The total number of minutes represented by this instance.

public double TotalSeconds { get; }

Gets the value of the current structure expressed in whole and fractional seconds.

  • Returns The total number of seconds represented by this instance.

public static bool TryParse( string input, IFormatProvider formatProvider, ref TimeSpan result )

Converts the string representation of a time interval to its equivalent by using the specified culture-specific formatting information, and returns a value that indicates whether the conversion succeeded.

  • input A string that specifies the time interval to convert.
  • formatProvider An object that supplies culture-specific formatting information.
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, . This operation returns if the parameter is or , has an invalid format, represents a time interval that is less than or greater than , or has at least one days, hours, minutes, or seconds component outside its valid range.

public static bool TryParse( string s, ref TimeSpan result )

Converts the string representation of a time interval to its equivalent and returns a value that indicates whether the conversion succeeded.

  • s A string that specifies the time interval to convert.
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, . This operation returns if the parameter is or , has an invalid format, represents a time interval that is less than or greater than , or has at least one days, hours, minutes, or seconds component outside its valid range.

public static bool TryParseExact( string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpan result )

Converts the string representation of a time interval to its equivalent by using the specified format, culture-specific format information, and styles, and returns a value that indicates whether the conversion succeeded. The format of the string representation must match the specified format exactly.

  • input A string that specifies the time interval to convert.
  • format A standard or custom format string that defines the required format of .
  • formatProvider An object that provides culture-specific formatting information.
  • styles One or more enumeration values that indicate the style of .
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, .

public static bool TryParseExact( string input, string format, IFormatProvider formatProvider, ref TimeSpan result )

Converts the string representation of a time interval to its equivalent by using the specified format and culture-specific format information, and returns a value that indicates whether the conversion succeeded. The format of the string representation must match the specified format exactly.

  • input A string that specifies the time interval to convert.
  • format A standard or custom format string that defines the required format of .
  • formatProvider An object that supplies culture-specific formatting information.
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, .

public static bool TryParseExact( string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpan result )

Converts the specified string representation of a time interval to its equivalent by using the specified formats, culture-specific format information, and styles, and returns a value that indicates whether the conversion succeeded. The format of the string representation must match one of the specified formats exactly.

  • input A string that specifies the time interval to convert.
  • formats A array of standard or custom format strings that define the acceptable formats of .
  • formatProvider An object that supplies culture-specific formatting information.
  • styles One or more enumeration values that indicate the style of .
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, .

public static bool TryParseExact( string input, string[] formats, IFormatProvider formatProvider, ref TimeSpan result )

Converts the specified string representation of a time interval to its equivalent by using the specified formats and culture-specific format information, and returns a value that indicates whether the conversion succeeded. The format of the string representation must match one of the specified formats exactly.

  • input A string that specifies the time interval to convert.
  • formats A array of standard or custom format strings that define the acceptable formats of .
  • formatProvider An object that provides culture-specific formatting information.
  • result When this method returns, contains an object that represents the time interval specified by , or if the conversion failed. This parameter is passed uninitialized.
  • Returns if was converted successfully; otherwise, .

public static TimeSpan Zero

Represents the zero value. This field is read-only.

public static long MicrosecondsPerMillisecond

😔 No documentation found.

public static long MicrosecondsPerMinute

😔 No documentation found.

public static long MicrosecondsPerHour

😔 No documentation found.

public static long MinutesPerHour

😔 No documentation found.

public static long SecondsPerDay

😔 No documentation found.

public static long MicrosecondsPerDay

😔 No documentation found.

public static long MillisecondsPerSecond

😔 No documentation found.

public static long MillisecondsPerMinute

😔 No documentation found.

public static long TicksPerMicrosecond

😔 No documentation found.

public static long MillisecondsPerDay

😔 No documentation found.

public static long NanosecondsPerTick

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public static long MicrosecondsPerSecond

😔 No documentation found.

public TimeSpan( int days, int hours, int minutes, int seconds, int milliseconds, int microseconds )

😔 No documentation found.

public static long SecondsPerHour

😔 No documentation found.

public static long MillisecondsPerHour

😔 No documentation found.

public static long SecondsPerMinute

😔 No documentation found.

public static int HoursPerDay

😔 No documentation found.

public static bool TryParse( ReadOnlySpan<char> input, IFormatProvider formatProvider, ref TimeSpan result )

😔 No documentation found.

public int Microseconds { get; }

😔 No documentation found.

public int Nanoseconds { get; }

😔 No documentation found.

public double TotalMicroseconds { get; }

😔 No documentation found.

public double TotalNanoseconds { get; }

😔 No documentation found.

public TimeSpan Duration( )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public static TimeSpan FromDays( int days )

😔 No documentation found.

public static TimeSpan FromDays( int days, int hours = 0, long minutes = 0, long seconds = 0, long milliseconds = 0, long microseconds = 0 )

😔 No documentation found.

public static TimeSpan FromHours( int hours )

😔 No documentation found.

public static TimeSpan FromHours( int hours, long minutes = 0, long seconds = 0, long milliseconds = 0, long microseconds = 0 )

😔 No documentation found.

public static TimeSpan FromMinutes( long minutes )

😔 No documentation found.

public static TimeSpan FromMinutes( long minutes, long seconds = 0, long milliseconds = 0, long microseconds = 0 )

😔 No documentation found.

public static TimeSpan FromSeconds( long seconds )

😔 No documentation found.

public bool TryFormat( Span<byte> utf8Destination, ref int bytesWritten, ReadOnlySpan<char> format = null, IFormatProvider formatProvider = null )

😔 No documentation found.

public static TimeSpan FromSeconds( long seconds, long milliseconds = 0, long microseconds = 0 )

😔 No documentation found.

public static TimeSpan FromMicroseconds( long microseconds )

😔 No documentation found.

public static TimeSpan FromMicroseconds( double value )

😔 No documentation found.

public TimeSpan Negate( )

😔 No documentation found.

public static TimeSpan Parse( ReadOnlySpan<char> input, IFormatProvider formatProvider = null )

😔 No documentation found.

public static TimeSpan ParseExact( ReadOnlySpan<char> input, ReadOnlySpan<char> format, IFormatProvider formatProvider, TimeSpanStyles styles = None )

😔 No documentation found.

public static TimeSpan ParseExact( ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles = None )

😔 No documentation found.

public static bool TryParse( ReadOnlySpan<char> s, ref TimeSpan result )

😔 No documentation found.

public static long MinutesPerDay

😔 No documentation found.

public static bool TryParseExact( ReadOnlySpan<char> input, ReadOnlySpan<char> format, IFormatProvider formatProvider, ref TimeSpan result )

😔 No documentation found.

public static bool TryParseExact( ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, ref TimeSpan result )

😔 No documentation found.

public static bool TryParseExact( ReadOnlySpan<char> input, ReadOnlySpan<char> format, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpan result )

😔 No documentation found.

public static bool TryParseExact( ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpan result )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public static TimeSpan FromMilliseconds( long milliseconds, long microseconds = 0 )

😔 No documentation found.

public bool TryFormat( Span<char> destination, ref int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider formatProvider = null )

😔 No documentation found.