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, DateTimeStyles)

Creates a DateTime from a string and uses DateTimeFormatInfo to format it with DateTimeStyles enumeration.

[Visual Basic]
Overloads Public Shared Function ParseExact( _
   ByVal s As String, _
   ByVal format As String, _
   ByVal dtfi As DateTimeFormatInfo, _
   ByVal style As DateTimeStyles _
) As DateTime
[C#]
public static DateTime ParseExact(
   string s,
   string format,
   DateTimeFormatInfo dtfi,
   DateTimeStyles style
);
[C++]
public: static DateTime ParseExact(
   String* s,
   String* format,
   DateTimeFormatInfo* dtfi,
   DateTimeStyles style
);
[JScript]
public static function ParseExact(
   s : String,
   format : String,
   dtfi : DateTimeFormatInfo,
   style : DateTimeStyles
) : DateTime;

Parameters

s
A string that contain the date and time.
format
The format needed for parsing.
dtfi
The DateTimeFormatInfo instance that provides the information to be parsed.
style
The particular parsing flags' applied by DateTimeStyles.

Return Value

A DateTime formatted in the valid string representation and style.

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 CultureInfo and DateTimeFormatInfo for a list of the format characters.

DateTimeStyles provides the particular parsing flags that are used.

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 | DateTimeFormat