DateTimeParse Method (String, IFormatProvider, DateTimeStyles) |
Converts the specified string representation of a date and time to its
DateTime equivalent using the specified culture-specific format information and formatting style.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static DateTime Parse(
string s,
IFormatProvider provider,
DateTimeStyles styles
)
Parameters
- s
- Type: SystemString
A string containing a date and time to convert. - provider
- Type: SystemIFormatProvider
An object that supplies culture-specific formatting information about s. - styles
- Type: System.GlobalizationDateTimeStyles
A bitwise combination of the enumeration values that indicates the style elements that can be present in s for the parse operation to succeed and that defines how to interpret the parsed date in relation to the current time zone or the current date. A typical value to specify is None.
Return Value
Type:
DateTimeAn object that is equivalent to the date and time contained in
s, as specified by
provider and
styles.
Exceptions Exception | Condition |
---|
ArgumentNullException | s is null. |
FormatException | s does not contain a valid string representation of a date and time. |
ArgumentException | styles contains an invalid combination of DateTimeStyles values. For example, both AssumeLocal and AssumeUniversal. |
See Also