Mono Class Library: System.DateTime Overview | Members

System.DateTime.Parse Method

Returns the specified string converted to a DateTime value.

public static DateTime Parse (string s, IFormatProvider provider, System.Globalization.DateTimeStyles styles)

Parameters

s
A string containing the value to convert.
provider
A IFormatProvider that supplies a System.Globalization.DateTimeFormatInfo object containing culture-specific format information about s .
styles
One or more System.Globalization.DateTimeStyles values that specify the style of s. Specify multiple values for styles using the bitwise OR operator.
styles
Documentation for this section has not yet been entered.

Returns

The DateTime value obtained from s.

Exceptions

TypeReason
ArgumentExceptions is a null reference.
FormatExceptions does not contain a valid string representation of a time or date and time.

Remarks

The string s is parsed using the culture-specific formatting information from the System.Globalization.DateTimeFormatInfo instance supplied by provider. If provider is null or a System.Globalization.DateTimeFormatInfo cannot be obtained from provider, the formatting information for the current system culture is used.

In order for the string to be successfully parsed, it is required to represent a date and time value in one of the standard DateTime patterns described in System.Globalization.DateTimeFormatInfo .

If the string contains only a time, and no date, and if the styles parameter is set to System.Globalization.DateTimeStyles.NoCurrentDateDefault the Gregorian year 1, month 1, day 1 are used. In all other cases where a date is not specified, the current date (DateTime.Now ) is used.

If the string contains only a date and no time, this method assumes 12 a.m.

For all settings of the styles parameter, any leading, trailing, and inner white space characters are ignored.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0