Click or drag to resize
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: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
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: DateTime
An object that is equivalent to the date and time contained in s, as specified by provider and styles.
Exceptions
ExceptionCondition
ArgumentNullExceptions is null.
FormatExceptions does not contain a valid string representation of a date and time.
ArgumentExceptionstyles contains an invalid combination of DateTimeStyles values. For example, both AssumeLocal and AssumeUniversal.
See Also