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)

Parameters

s
A string containing a value to convert. The string is interpreted using the System.Globalization.DateTimeStyles.None style.

Returns

The DateTime value obtained from s.

Exceptions

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

Remarks

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

The string s is parsed using the formatting information in a System.Globalization.DateTimeFormatInfo initialized for the current system culture.

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.

Requirements

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