N
Nicholas Paldino [.NET/C# MVP]
Hari,
For now, the exception is the best way to do it (there is no reason to
duplicate the code). I would write a little wrapper method that calls Parse
(or Parse exact) and catches the exception.
You could also try the static IsDate method on the Interaction class in
the Microsoft.VisualBasic namespace. I don't know that the processing is
exactly the same as Parse, so you might want to check it with a few cases
before you try it.
When .NET 2.0 is released, you can call the static TryParse method on
the DateTime class to try and parse the date without throwing an exception
if it fails.
Hope this helps.
For now, the exception is the best way to do it (there is no reason to
duplicate the code). I would write a little wrapper method that calls Parse
(or Parse exact) and catches the exception.
You could also try the static IsDate method on the Interaction class in
the Microsoft.VisualBasic namespace. I don't know that the processing is
exactly the same as Parse, so you might want to check it with a few cases
before you try it.
When .NET 2.0 is released, you can call the static TryParse method on
the DateTime class to try and parse the date without throwing an exception
if it fails.
Hope this helps.