DateTimeTryParse Method (String, DateTime) |
Converts the specified string representation of a date and time to its
DateTime equivalent and returns a value that indicates whether the conversion succeeded.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static bool TryParse(
string s,
out DateTime result
)
Parameters
- s
- Type: SystemString
A string containing a date and time to convert. - result
- Type: SystemDateTime
When this method returns, contains the DateTime value equivalent to the date and time contained in s, if the conversion succeeded, or MinValue if the conversion failed. The conversion fails if the s parameter is null, is an empty string (""), or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.
Return Value
Type:
Booleantrue if the
s parameter was converted successfully; otherwise, false.
Exceptions Exception | Condition |
---|
ArgumentOutOfRangeException | The date is in Japanese Emperor Year (Wareki) format and the year is out of range. |
See Also