Date Validation

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
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.
 
Friends,

Can anyone tell me how to validate a date in C#, Actually I need any other
way than jumping to exception.

-Hari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top