NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DateTime.ParseExact (String, String, DateTimeFormatInfo)

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;

Parameters

s
A string containing the date and time.
format
The format needed for parsing.
dtfi
The DateTimeFormatInfo instance providing the information to be parsed.

Return Value

A DateTime formatted in the valid string representation.

Exceptions

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.

Remarks

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.

See Also

DateTime Structure | DateTime Members | System Namespace | DateTime.ParseExact Overload List | String | DateTimeFormatInfo | Format | CultureInfo