TimeSpan.TryParseExact Method (String, String, IFormatProvider, TimeSpan%)
Converts the string representation of a time interval to its TimeSpan 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.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function TryParseExact ( _ input As String, _ format As String, _ formatProvider As IFormatProvider, _ <OutAttribute> ByRef result As TimeSpan _ ) As Boolean
- Type: System.String
A string that specifies the time interval to convert.
- Type: System.String
A standard or custom format string that defines the required format of input.
- Type: System.IFormatProvider
An object that supplies culture-specific formatting information.
Return ValueType: System.Boolean
true if input was converted successfully; otherwise, false.
The 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. This method is similar to the ParseExact(String, String, IFormatProvider) method, except that it does not throw an exception if the conversion fails.
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:
A CultureInfo object that represents the culture whose formatting conventions are to be reflected in the returned string. The DateTimeFormatInfo object returned by the CultureInfo.DateTimeFormat property defines the formatting of the returned string.
A DateTimeFormatInfo object that defines the formatting of the returned string.
If formatProvider is Nothing, the DateTimeFormatInfo object that is associated with the current culture is used.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.