Wednesday, May 19, 2004

Undoc'd exception on DateTime.Parse

The .NET Framework Class Library documentation for DateTime's Parse method identifies two exceptions that may occur: ArgumentNullException and FormatException. When using this method, however, I found that it also throws ArgumentOutOfRangeException for dates that have valid formats but are out of range. For example:

   DateTime.Parse( "1/1/20000" );    // oops! year = 20,000

will throw ArgumentOutOfRangeException.

No comments: