Exportar (0) Imprimir
Expandir todo

TimeSpan.ParseExact Method (String, String, IFormatProvider, TimeSpanStyles)

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

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

Parameters

input
Type: System.String
A string that specifies the time interval to convert.
format
Type: System.String
A standard or custom format string that defines the required format of input.
formatProvider
Type: System.IFormatProvider
An object that provides culture-specific formatting information.
styles
Type: System.Globalization.TimeSpanStyles
A bitwise combination of enumeration values that defines the style elements that may be present in input.

Return Value

Type: System.TimeSpan
A time interval that corresponds to input, as specified by format, formatProvider, and styles.

ExceptionCondition
ArgumentException

styles is an invalid TimeSpanStyles value.

ArgumentNullException

input is null.

FormatException

input has an invalid format.

OverflowException

input represents a number that is less than TimeSpan.MinValue or greater than TimeSpan.MaxValue.

-or-

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

The ParseExact method parses the string representation of a time interval, which must be in the format defined by the format parameter, except that leading and trailing white-space characters are ignored.

The format 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 input. For more information about valid format strings, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.

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

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

The styles parameter determines whether input is interpreted as a negative time interval only if a negative sign is present (TimeSpanStyles.None), or whether it is always interpreted as a negative time interval (TimeSpanStyles.AssumeNegative).

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft