System.IFormatProvider format = new System.Globalization.CultureInfo("en-US", true);
DateTime outDate;
bool isDate = DateTime.TryParseExact("08112008", "MMddyyyy", format,
System.Globalization.DateTimeStyles.AllowWhiteSpaces, out outDate);
The TryParseExact method allows you specify the exact formatting of the input string. If the Parse is successful, the boolean returned will be True - and the output DateTime variable will contain a valid date.
0 comments:
Post a Comment