Mono Class Library: System.DateTime Overview | Members

System.DateTime.Parse Method

Returns the specified string converted to a DateTime value. [Edit]

public static DateTime Parse (string s, IFormatProvider provider)

Parameters

s
A string containing the value to convert. The string is interpreted using the System.Globalization.DateTimeStyles.None style. [Edit]
provider
A IFormatProvider that supplies a System.Globalization.DateTimeFormatInfo object containing culture-specific format information about s . [Edit]

Returns

The DateTime value obtained from s. [Edit]

Exceptions

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

Remarks

This version of DateTime.Parse(string) is equivalent to DateTime.Parse(string)(s, provider, System.Globalization.DateTimeStyles.None ).

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, then the current date (DateTime.Now ) is used. If the string contains only a date and no time, this method assumes 12 a.m.

Any leading, trailing, and inner white space characters are ignored.

[Edit]

Requirements

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