Creates a DateTime from a string.
[Visual Basic] Overloads Public Shared Function Parse( _ ByVal s As String _ ) As DateTime [C#] public static DateTime Parse( string s ); [C++] public: static DateTime Parse( String* s ); [JScript] public static function Parse( s : String ) : DateTime;
A new DateTime.
Exception Type | Condition |
---|---|
ArgumentNullException | If s is a null reference (in Visual Basic Nothing). |
FormatException | If s does not contain a valid string representation and therefore cannot be parsed according to the DateTimeFormatInfo object used. |
The Parse and ParseExact methods each break the input into smaller chunks, but the ParseExact also looks for a specific (exact) string.
In order for the string to be successfully parsed, it must represent a date and time value in either of:
Leading and trailing white space characters are allowed.
DateTime Structure | DateTime Members | System Namespace | DateTime.Parse Overload List | String | DateTimeFormatInfo | DateTimeFormat | CultureInfo