BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.ValueType System.IComparable System.IComparable<System.TimeSpan> System.IEquatable<System.TimeSpan> System.IFormattable System.Runtime.InteropServices.ComVisible(true)

A object represents a time interval (duration of time or elapsed time) that is measured as a positive or negative number of days, hours, minutes, seconds, and fractions of a second. The structure can also be used to represent the time of day, but only if the time is unrelated to a particular date. Otherwise, the or structure should be used instead. (For more information about using the structure to reflect the time of day, see Choosing Between DateTime, DateTimeOffset, and TimeZoneInfo.)

The largest unit of time that the structure uses to measure duration is a day. Time intervals are measured in days for consistency, because the number of days in larger units of time, such as months and years, varies.

The value of a 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 object can range from to .

## Instantiating a TimeSpan Value

You can instantiate a value in a number of ways:

By calling its implicit default constructor. This creates an object whose value is , as the following example shows.

code reference: System.TimeSpan.Class#2

By calling one of its explicit constructors. The following example initializes a value to a specified number of hours, minutes, and seconds.

code reference: System.TimeSpan.Class#3

By calling a method or performing an operation that returns a value. For example, you can instantiate a value that represents the interval between two date and time values, as the following example shows.

code reference: System.TimeSpan.Class#4

You can also initialize a object to a zero time value in this way, as the following example shows.

code reference: System.TimeSpan.Class#6

values are returned by arithmetic operators and methods of the , , and structures.

By parsing the string representation of a value. You can use the and methods to convert strings that contain time intervals to values. The following example uses the method to convert an array of strings to values.

code reference: System.TimeSpan.Class#5

In addition, you can define the precise format of the input string to be parsed and converted to a value by calling the or method.

## Performing Operations on TimeSpan Values

You can add and subtract time durations either by using the and operators, or by calling the and methods. You can also compare two time durations by calling the , , and methods. The class also includes the and methods, which convert time intervals to positive and negative values,

The range of values is to .

## Formatting a TimeSpan Value

A 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. That is, a time interval consists of a positive or negative number of days without a time of day, or a number of days with a time of day, or only a time of day.

Beginning with the net_v40_long, the structure supports culture-sensitive formatting through the overloads of its method, which converts a value to its string representation. The default method returns a time interval by using an invariant format that is identical to its return value in previous versions of the .NET Framework. The overload lets you specify a format string that defines the string representation of the time interval. The overload lets you specify a format string and the culture whose formatting conventions are used to create the string representation of the time interval. supports both standard and custom format strings. (For more information, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.) However, only standard format strings are culture-sensitive.

## Restoring Legacy TimeSpan Formatting

In some cases, code that successfully formats values in net_v35_short and earlier versions fails in net_v40_short. This is most common in code that calls a composite formatting method to format a value with a format string. The following example successfully formats a value in net_v35_short and earlier versions, but throws an exception in net_v40_short and later versions. Note that it attempts to format a value by using an unsupported format specifier, which is ignored in net_v35_short and earlier versions.

code reference: System.TimeSpan.Class.Legacy#1

If you cannot modify the code, you can restore the legacy formatting of values in one of the following ways:

By creating a configuration file that contains the <TimeSpan_LegacyFormatMode> element. Setting this element's enabled attribute to true restores legacy formatting on a per-application basis.

By setting the "NetFx40_TimeSpanLegacyFormatMode" compatibility switch when you create an application domain. This enables legacy formatting on a per-application-domain basis. The following example creates an application domain that uses legacy formatting.

code reference: System.TimeSpan.Class.AppDomain#1

When the following code executes in the new application domain, it reverts to legacy formatting behavior.

code reference: System.TimeSpan.Class.AppDomain#2

Represents a time interval.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

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

  A time period expressed in 100-nanosecond units.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The parameters specify a value less than or greater than .

  The specified , , and are converted to ticks, and that value initializes this instance.

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

  Number of hours.
  Number of minutes.
  Number of seconds.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The parameters specify a value less than or greater than .

  The specified , , , and are converted to ticks, and that value initializes this instance.

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

  Number of days.
  Number of hours.
  Number of minutes.
  Number of seconds.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The parameters specify a value less than or greater than .

  The specified , , , , and are converted to ticks, and that value initializes this instance.

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

  Number of days.
  Number of hours.
  Number of minutes.
  Number of seconds.
  Number of milliseconds.
  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The sum of the value of the current instance and the value of is less than or greater than .

  This example demonstrates the method.

  `using System; public class TimeSpanAddExample { public static void Main() { TimeSpan ts = new TimeSpan(Int32.MaxValue); Console.WriteLine("The value of the timespan 'ts' is {0}", ts); Console.WriteLine("ts.Add(ts) = {0}", ts.Add(ts)); } }`

  The output is

  The value of the timespan 'ts' is 00:03:34.7483647

  ts.Add(ts) = 00:07:09.4967294

  The return value must be between and ; otherwise, an exception is thrown.

  The return value is a new ; the original is not modified.

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

  A new object that represents the value of this instance plus the value of .

  The time interval to add. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` To be added.

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

  One of the following values.

  Value

  Description

  -1

  is shorter than .

  0

  is equal to .

  1

  is longer than .

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  is not a and is not a null reference.

  Any instance of , regardless of its value, is considered greater than null.

  The parameter must be an instance of or null; otherwise, an exception is thrown.

  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.

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

  An object to compare, or null. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method implements the interface and performs slightly better than the method because it does not have to convert the parameter to an object.

  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.

  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 .

  An object to compare to this instance.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A represents the days component of the current instance. See for a more detailed description of the days component.

  This example demonstrates using the property.

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

  The output is

  11.13:46:40.3456789

  Days: 11

  A 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 property is the day component, d.

  The property represents whole days, whereas the property represents whole and fractional days.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan To be added. The value of the current instance is .

  The following example demonstrates the method.

  `using System; public class TimeSpanDurationExample { public static void Main() { TimeSpan ts = new TimeSpan(Int32.MinValue); Console.Write("The absolute value of TimeSpan {0} ", ts); Console.WriteLine("is {0}", ts.Duration()); } }`

  The output is

  The absolute value of TimeSpan -00:03:34.7483648 is 00:03:34.7483648

  Returns a new object whose value is the absolute value of the current object.

  A new object whose value is the absolute value of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method overrides .

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

  true if is a object that represents the same time interval as the current structure; otherwise, false.

  An object to compare with this instance. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method implements the interface, and performs slightly better than because it does not have to convert the the parameter to an object.

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

  true if represents the same time interval as this instance; otherwise, false.

  An object to compare with this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

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

  true if the values of and are equal; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The represented by is greater than or less than . is equal to .

  The parameter is converted to milliseconds, which is converted to ticks, and that number of ticks is used to initialize the new . Therefore, will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the data type, this conversion can cause an for values that are near to but still in the range of either or . For example, this causes an in the following attempt to instantiate a object.

  code reference: System.TimeSpan.FromMinutes#2

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

  An object that represents .

  A number of days, accurate to the nearest millisecond. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The represented by is greater than or less than . is equal to .

  The parameter is converted to milliseconds, which is converted to ticks, and that number of ticks is used to initialize the new . Therefore, will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the data type, this conversion can generate an for values that are near to but still in the range of either or . For example, this causes an in the following attempt to instantiate a object.

  code reference: System.TimeSpan.FromMinutes#3

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

  An object that represents .

  A number of hours accurate to the nearest millisecond. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The represented by is greater than or less than . is equal to .

  The parameter is converted to ticks, and that number of ticks is used to initialize the new . Therefore, will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the data type, this conversion can generate an for values that are near to but still in the range of either or . For example, this causes an in the following attempt to instantiate a object.

  code reference: System.TimeSpan.FromMinutes#4

  Returns a that represents a specified number of milliseconds.

  An object that represents .

  A number of milliseconds. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The represented by is greater than or less than . is equal to .

  The parameter is converted to milliseconds, which is converted to ticks, and that number of ticks is used to initialize the new . Therefore, will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the data type, this conversion can generate an for values that are near to but still in the range of either or . For example, this causes an in the following attempt to instantiate a object.

  code reference: System.TimeSpan.FromMinutes#1

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

  An object that represents .

  A number of minutes, accurate to the nearest millisecond. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The represented by is greater than or less than . is equal to .

  The parameter is converted to milliseconds, which is converted to ticks, and that number of ticks is used to intialize the new . Therefore, will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the data type, this can generate an for values that are near but still in the range of either or , This is the cause of an , for example, in the following attempt to instantiate a object.

  code reference: System.TimeSpan.FromMinutes#5

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

  An object that represents .

  A number of seconds, accurate to the nearest millisecond. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan ``

  This is a convenience method with the same behavior as the constructor. A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

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

  An object that represents .

  A number of ticks that represent a time. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  Two objects might have the same hash code even though they represent different time values.

  Returns a hash code for this instance.

  A 32-bit signed integer hash code.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 23 inclusive, that represents the hours component of the current instance. See for a more detailed description of the hours component.

  This example demonstrates using the property.

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

  The output is

  11.13:46:40.3456789

  Hours: 13

  A 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 property is the hours component, hh.

  The property represents whole hours, whereas the property represents whole and fractional hours.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan

  The value of this field is equivalent to ticks. The string representation of this value is positive 10675199.02:48:05.4775807, or slightly more than 10,675,199 days.

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

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 999 inclusive, that represents the fractional seconds component of the current instance converted to milliseconds. See for a more detailed description of the fractional seconds component.

  This example demonstrates using the property.

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

  The output is

  11.13:46:40.3456789

  Milliseconds: 345

  A 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 property is the fractional second component, ff.

  The property represents whole milliseconds, whereas the property represents whole and fractional milliseconds.

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

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 59 inclusive, that represents the minutes component of the current instance. See for a more detailed description of the minutes component.

  This example demonstrates using the property.

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

  The output is

  11.13:46:40.3456789

  Minutes: 46

  A 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 property is the minute component, mm.

  The property represents whole minutes, whereas the property represents whole and fractional minutes.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan

  The value of this field is equivalent to ticks. The string representation of this value is negative 10675199.02:48:05.4775808, or slightly more than negative 10,675,199 days.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan To be added. The value of the current instance is .

  Returns a new object whose value is the negated value of this instance.

  A new object with the same numeric value as this instance, but with the opposite sign.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` `` The sum of and is less than or greater than .

  The method defines the addition operator for values. It enables code such as the following:

  code reference: System.TimeSpan.Operators#1

  Languages that do not support custom operators can call the method instead.

  Adds two specified instances.

  An object whose value is the sum of the values of and .

  The first time interval to add. The second time interval to add. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added. The first time interval to compare. The second time interval to compare.

  Indicates whether two instances are equal.

  true if the values of and are equal; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

  Indicates whether a specified is greater than another specified .

  true if the value of is greater than the value of ; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

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

  true if the value of is greater than or equal to the value of ; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

  Indicates whether two instances are not equal.

  true if the values of and are not equal; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

  Indicates whether a specified is less than another specified .

  true if the value of is less than the value of ; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added.

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

  true if the value of is less than or equal to the value of ; otherwise, false.

  The first time interval to compare. The second time interval to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` `` To be added. The value of subtracted from is less than or greater than .

  Subtracts a specified from another specified .

  An object whose value is the result of the value of minus the value of .

  The minuend. The subtrahend. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` To be added. equals .

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

  An object that has the same numeric value as this instance, but the opposite sign.

  The time interval to be negated. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan ``

  This method returns .

  Returns the specified instance of .

  The time interval specified by .

  The time interval to return. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` is a null reference. is in an invalid format.

  represents a number greater than or less than .

  -or-

  At least one of the hours, minutes, or seconds components is outside its valid range.

  This example demonstrates parsing a string to obtain a .

  `using System; public class TimeSpanParseExample { public static void Main() { String str = " -5.12:34:56.789 "; TimeSpan ts = TimeSpan.Parse(str); Console.WriteLine(@"The string ""{0}""", str); Console.WriteLine("parses to TimeSpan {0}", ts); } }`

  The output is

  `The string " -5.12:34:56.789 " parses to TimeSpan -5.12:34:56.7890000`

  The parameter contains a time interval specification in the form:

  [ws][-]{ d | [d.]hh:mm[:ss[.ff]] }[ws]

  Elements in square brackets ([ and ]) are optional. One selection from the list of alternatives enclosed in braces ({ and }) and separated by vertical bars (|) is required. The following table describes each element.

  Element

  Description

  ws

  Optional white space.

  -

  An optional minus sign, which indicates a negative .

  d

  Days, ranging from 0 to 10675199.

  .

  A culture-sensitive symbol that separates days from hours. The invariant format uses a period (".") character.

  hh

  Hours, ranging from 0 to 23.

  :

  The culture-sensitive time separator symbol. The invariant format uses a colon (":") character.

  mm

  Minutes, ranging from 0 to 59.

  ss

  Optional seconds, ranging from 0 to 59.

  .

  A culture-sensitive symbol that separates seconds from fractions of a second. The invariant format uses a period (".") character.

  ff

  Optional fractional seconds, consisting of one to seven decimal digits.

  The components of must collectively specify a time interval that is greater than or equal to and less than or equal to .

  The method tries to parse by using each of the culture-specific formats for the current culture.

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

  A time interval that corresponds to .

  A string that specifies the time interval to convert. 0
- Method
  4.0.0.0
  System.TimeSpan `` ``

  The parameter contains a time interval specification in the form:

  [ws][-]{ d | [d.]hh:mm[:ss[.ff]] }[ws]

  Elements in square brackets ([ and ]) are optional; one selection from the list of alternatives enclosed in braces ({ and }) and separated by vertical bars (|) is required. The following table describes each element.

  Element

  Description

  ws

  Optional white space.

  -

  An optional minus sign, which indicates a negative .

  d

  Days, ranging from 0 to 10675199.

  .

  A culture-sensitive symbol that separates days from hours. The default value is a period (".") character.

  hh

  Hours, ranging from 0 to 23.

  :

  The culture-sensitive time separator symbol.

  mm

  Minutes, ranging from 0 to 59.

  ss

  Optional seconds, ranging from 0 to 59.

  .

  A culture-sensitive symbol that separates seconds from fractions of a second. The default value is a period (".") character.

  ff

  Optional fractional seconds, consisting of one to seven decimal digits.

  The components of must collectively specify a time interval that is greater than or equal to and less than or equal to .

  The method tries to parse by using each of the culture-specific formats for the culture specified by .

  The parameter is an implementation that provides culture-specific information about the format of the returned string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used.

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

  A time interval that corresponds to , as specified by .

  A string that specifies the time interval to convert. An object that supplies culture-specific formatting information.
- Method
  4.0.0.0
  System.TimeSpan `` `` ``

  The method parses the string representation of a time interval, which must be in the format defined by the parameter, except that leading and trailing white-space characters are ignored. Because must conform to the format of exactly, you should always use exception handling when converting a string input by the user to a time interval. If you prefer not to use exception handling, you can call the method instead.

  The parameter is a string that contains either a single standard format specifier, or one or more custom format specifiers that define the required format of . For more information about valid format strings, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.

  The method uses the conventions of the culture specified by the parameter only if is a standard format string whose value is either "g" or "G". The "c", "t", and "T" standard format strings use the formatting conventions of the invariant culture. Custom format strings define the precise format of the input string and use literal characters to separate the components of a time interval.

  The parameter is an implementation that provides culture-specific information about the format of the returned string if is a standard format string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used.

  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.

  A time interval that corresponds to , as specified by and .

  A string that specifies the time interval to convert. A standard or custom format string that defines the required format of . An object that provides culture-specific formatting information.
- Method
  4.0.0.0
  System.TimeSpan `` `` ``

  The method parses the string representation of a time interval, which must be in one of the formats defined by the parameter, except that leading and trailing white-space characters are ignored. Because must exactly conform to one of the formats specified in , you should always use exception handling when converting a string input by the user to a time interval. If you prefer not to use exception handling, you can call the method instead.

  The parameter is a string array whose elements consist of either a single standard format specifier, or one or more custom format specifiers that define the required format of . For more information about valid format strings, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings. must correspond exactly to a member of for the parse operation to succeed. The parse operation attempts to match to each element in starting with the first element in the array.

  The method uses the conventions of the culture specified by the parameter only if the format string used to parse is a standard format string whose value is either "g" or "G". The "c", "t", and "T" standard format strings use the formatting conventions of the invariant culture. Custom format strings define the precise format of the input string and use literal characters to separate the components of a time interval.

  The parameter is an implementation that provides culture-specific information about the format of the returned string if the format string used to parse is a standard format string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used.

  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.

  A time interval that corresponds to , as specified by and .

  A string that specifies the time interval to convert. A array of standard or custom format strings that defines the required format of . An object that provides culture-specific formatting information.
- Method
  4.0.0.0
  System.TimeSpan `` `` `` ``

  The method parses the string representation of a time interval, which must be in the format defined by the parameter, except that leading and trailing white-space characters are ignored. Because must conform to the format of exactly, you should always use exception handling when converting a string input by the user to a time interval. If you prefer not to use exception handling, you can call the method instead.

  The parameter is a string that contains either a single standard format specifier, or one or more custom format specifiers that define the required format of . For more information about valid format strings, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.

  The method uses the conventions of the culture specified by the parameter only if is a standard format string whose value is either "g" or "G". The "c", "t", and "T" standard format strings use the formatting conventions of the invariant culture. Custom format strings define the precise format of the input string and use literal characters to separate the components of a time interval.

  The parameter is an implementation that provides culture-specific information about the format of the returned string if is a standard format string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used.

  The parameter affects the interpretation of strings that are parsed using custom format strings. It determines whether is interpreted as a negative time interval only if a negative sign is present (), or whether it is always interpreted as a negative time interval (). If is not used, must include a literal negative sign symbol (such as "\-") to successfully parse a negative time interval.

  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.

  A time interval that corresponds to , as specified by , , and .

  A string that specifies the time interval to convert. A standard or custom format string that defines the required format of . An object that provides culture-specific formatting information. A bitwise combination of enumeration values that defines the style elements that may be present in .
- Method
  4.0.0.0
  System.TimeSpan `` `` `` ``

  The method parses the string representation of a time interval, which must be in one of the formats defined by the parameter, except that leading and trailing white-space characters are ignored. Because must exactly conform to one of the formats specified in , you should always use exception handling when converting a string input by the user to a time interval. If you prefer not to use exception handling, you can call the method instead.

  The parameter is a string array whose elements consist of either a single standard format specifier, or one or more custom format specifiers that define the required format of . For more information about valid format strings, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings. must correspond exactly to a member of for the parse operation to succeed. The parse operation attempts to match to each element in starting with the first element in the array.

  The method uses the conventions of the culture specified by the parameter only if the format string used to parse is a standard format string whose value is either "g" or "G". The "c", "t", and "T" standard format strings use the formatting conventions of the invariant culture. Custom format strings define the precise format of the input string and use literal characters to separate the components of a time interval.

  The parameter is an implementation that provides culture-specific information about the format of the returned string if the format string used to parse is a standard format string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used.

  The parameter affects the interpretation of strings that are parsed using custom format strings. It determines whether is interpreted as a negative time interval only if a negative sign is present (), or whether it is always interpreted as a negative time interval (). If is not used, must include a literal negative sign symbol (such as "\-") to successfully parse a negative time interval.

  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.

  A time interval that corresponds to , as specified by , , and .

  A string that specifies the time interval to convert. A array of standard or custom format strings that define the required format of . An object that provides culture-specific formatting information. A bitwise combination of enumeration values that defines the style elements that may be present in input.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

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

  This example demonstrates using the property.

  `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

  A 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 property is the seconds component, ss.

  The property represents whole seconds, whereas the property represents whole and fractional seconds.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` The difference between the value of the current instance and is less than or greater than .

  The return value must be between and ; otherwise, an exception is thrown.

  The return value is a new ; the original is not modified.

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

  A new time interval whose value is the result of the value of this instance minus the value of .

  The time interval to be subtracted. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64

  A specifying the number of ticks represented by the current instance.

  The smallest unit of time is the tick, which is equal to 100 nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond. The value of the property can be negative or positive to represent a negative or positive time interval.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 864000000000

  The value of this constant is 864 billion; that is, 864,000,000,000.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 36000000000

  The value of this constant is 36 billion; that is, 36,000,000,000.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 10000

  The value of this constant is 10 thousand; that is, 10,000.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 600000000

  The value of this constant is 600 million; that is, 600,000,000.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 10000000

  The value of this constant is 10 million; that is, 10,000,000.

  Represents the number of ticks in 1 second.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  This example demonstrates the method.

  `using System; public class TimeSpanToStringExample { public static void Main() { TimeSpan tsOne = new TimeSpan(1, 23, 45, 54, 321); TimeSpan tsTwo = new TimeSpan(0, 23, 45, 54, 0); Console.Write("TimeSpan one, with d. and .ff: "); Console.WriteLine("{0}", tsOne.ToString()); Console.Write("TimeSpan two, without d. and .ff: "); Console.WriteLine("{0}", tsTwo.ToString()); } }`

  The output is

  TimeSpan one, with d. and .ff: 1.23:45:54.3210000

  TimeSpan two, without d. and .ff: 23:45:54

  The returned string is formatted with the "c" format specifier and has the following format:

  [-][d.]hh:mm:ss[.fffffff]

  Elements in square brackets ([ and ]) may not be included in the returned string. Colons and periods (: and.) are literal characters. The non-literal elements are listed in the following table. Note that the string returned by the method is not culture-sensitive.

  Item

  Description

  "-"

  A minus sign, which indicates a negative time interval. No sign is included for a positive time span.

  "d"

  The number of days in the time interval. This element is omitted if the time interval is less than one day.

  "hh"

  The number of hours in the time interval, ranging from 0 to 23.

  "mm"

  The number of minutes in the time interval, ranging from 0 to 59.

  "ss"

  The number of seconds in the time interval, ranging from 0 to 59.

  "fffffff"

  Fractional seconds in the time interval. This element is omitted if the time interval does not include fractional seconds. If present, fractional seconds are always expressed using seven decimal digits.

  For more information about comparing the string representation of and Oracle data types, see Knowledge Base article 324577: System.TimeSpan Does Not Match Oracle 9i INTERVAL DAY TO SECOND Data Type.

  Converts the value of the current object to its equivalent string representation.

  The string representation of the current value.

  0
- Method
  4.0.0.0
  System.String ``

  The parameter can be any valid standard or custom format specifier for values. If is equal to or is null, the return value of the current object is formatted with the common format specifier ("c"). If is any other value, the method throws a .

  If is a standard format string, the format of the returned string is defined by the formatting conventions of the current culture.

  The custom format strings for values do not include a date or time separator. If you want to include these elements in your format string, you must treat them as character literals. See the example for an illustration, and see the Custom TimeSpan Format Strings topic for more information.

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about format strings for values, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.

  For more information about support for formatting in the .NET Framework, see Formatting Types.

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

  The string representation of the current value in the format specified by the parameter.

  A standard or custom format string.
- Method
  4.0.0.0
  System.String `` ``

  The parameter can be any valid standard or custom format specifier for values. If is equal to or is null, the return value of the current object is formatted with the common format specifier ("c"). If format is any other value, the method throws a .

  The custom format strings for values do not include a date or time separator. If you want to include these elements in your format string, you must treat them as character literals. See the example for an illustration, and see the Custom TimeSpan Format Strings topic for more information.

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about format strings for values, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.

  For more information about support for formatting in the .NET Framework, see Formatting Types.

  The parameter is an implementation that provides culture-specific information about the format of the returned string. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object retuned by the property defines the formatting of the returned string.

  A object that defines the formatting of the returned string.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object that is associated with the current culture is used. If is a custom format string, the parameter is ignored.

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

  The string representation of the current value, as specified by and .

  A standard or custom format string. An object that supplies culture-specific formatting information.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  A that specifies the total number of days represented by the current instance.

  This example demonstrates using the property.

  `using System; public class TimeSpanTotalUnitsProperties{ public static void Main() { TimeSpan ts = new TimeSpan((Int64)10e12); Console.WriteLine(ts.ToString()); Console.WriteLine("TotalDays: {0}", ts.TotalDays); } }`

  The output is

  11.13:46:40

  TotalDays: 11.5740740740741

  This property converts the value of this instance from ticks to days. This number might include whole and fractional days.

  The property represents whole and fractional days, whereas the property represents whole days.

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

  1
  ExtendedNumerics
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  A that specifies the total number of hours represented by the current instance.

  This example demonstrates using the property.

  `using System; public class TimeSpanTotalUnitsProperties{ public static void Main() { TimeSpan ts = new TimeSpan((Int64)10e12); Console.WriteLine(ts.ToString()); Console.WriteLine("TotalHours: {0}", ts.TotalHours); } }`

  The output is

  11.13:46:40

  TotalHours: 277.777777777778

  This property converts the value of this instance from ticks to hours. This number might include whole and fractional hours.

  The property represents whole and fractional hours, whereas the property represents whole hours.

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

  1
  ExtendedNumerics
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  A that specifies the total number of milliseconds represented by the current instance.

  This example demonstrates using the property.

  `using System; public class TimeSpanTotalUnitsProperties{ public static void Main() { TimeSpan ts = new TimeSpan((Int64)10e12); Console.WriteLine(ts.ToString()); Console.WriteLine("TotalMilliseconds: {0}", ts.TotalMilliseconds); } }`

  The output is

  11.13:46:40

  TotalMilliseconds: 1000000000

  This property converts the value of this instance from ticks to milliseconds. This number might include whole and fractional milliseconds.

  The property represents whole and fractional milliseconds, whereas the property represents whole milliseconds.

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

  1
  ExtendedNumerics
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  A that specifies the total number of minutes represented by the current instance.

  This example demonstrates using the property.

  `using System; public class TimeSpanTotalUnitsProperties{ public static void Main() { TimeSpan ts = new TimeSpan((Int64)10e12); Console.WriteLine(ts.ToString()); Console.WriteLine("TotalMinutes: {0}", ts.TotalMinutes); } }`

  The output is

  11.13:46:40

  TotalMinutes: 16666.6666666667

  This property converts the value of this instance from ticks to minutes. This number might include whole and fractional minutes.

  The property represents whole and fractional minutes, whereas the property represents whole minutes.

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

  1
  ExtendedNumerics
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  A that specifies the total number of seconds represented by the current instance.

  This example demonstrates using the property.

  `using System; public class TimeSpanTotalUnitsProperties{ public static void Main() { TimeSpan ts = new TimeSpan((Int64)10e12); Console.WriteLine(ts.ToString()); Console.WriteLine("TotalSeconds: {0}", ts.TotalSeconds); } }`

  The output is

  11.13:46:40

  TotalSeconds :1000000

  This property converts the value of this instance from ticks to seconds. This number might include whole and fractional seconds.

  The property represents whole and fractional seconds, whereas the property represents whole seconds.

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

  1
  ExtendedNumerics
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan

  Because the value of the field is a object that represents a zero time value, you can compare it with other objects to determine whether the latter represent positive, non-zero, or negative time intervals. You can also use this field to initialize a object to a zero time value.

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

  0
0