Possible Duplicate:
DateTime.TryParse century control C#
I need to TryParse a string such as the following: “01/01/99” into a DateTime object, and I’m using something like this:
DateTime outDate;
if (DateTime.TryParseExact("01/01/99", "dd/MM/yy", null, System.Globalization.DateTimeStyles.None, out outDate))
{
//Do stuff here
}
Of course, this date gets parsed as 01/01/1999, which is not what I want – I want it to parse as 2099. Is there an easy way to do this? Sadly modifying the data I’m parsing to include the full year is not an option.
Taken from this answer, you can supply
ParseExact()with a culture object. SuspectTryParseExact()would be the same: