Creates a DateTime from a string and uses DateTimeFormatInfo to format it.
[Visual Basic] Overloads Public Shared Function ParseExact( _ ByVal s As String, _ ByVal format As String, _ ByVal dtfi As DateTimeFormatInfo _ ) As DateTime [C#] public static DateTime ParseExact( string s, string format, DateTimeFormatInfo dtfi ); [C++] public: static DateTime ParseExact( String* s, String* format, DateTimeFormatInfo* dtfi ); [JScript] public static function ParseExact( s : String, format : String, dtfi : DateTimeFormatInfo ) : DateTime;
A DateTime formatted in the valid string representation.
Exception Type | Condition |
---|---|
ArgumentNullException | If the string is a null reference (in Visual Basic Nothing). |
FormatException | If the string does not contain a valid string representation of a date and time. |
FormatException | If the format uses the general format ("G") string. |
The Parse and ParseExact methods each break the input into smaller chunks, but the ParseExact also looks for a specific (exact) string.
ParseExact constructs a DateTime from a string. The string must specify a date and, optionally, a time in a culture-specific or universal format. See DateTimeFormat for a list of the format characters.
Leading and trailing white space characters are allowed.
An unexpected FormatException occurs while using the ToString general format ("G") string when the general format DateTime string representation is not parsed correctly.
DateTime Structure | DateTime Members | System Namespace | DateTime.ParseExact Overload List | String | DateTimeFormatInfo | Format | CultureInfo