How to check whether Date is valid or not?

 Posted by vishalneeraj-24503 on 12/3/2014 | Category: C# Interview questions | Views: 766 | Points: 40
Answer:

By using DateTime.Parse Method,we can check whether Date is valid or not.DateTime.Parse method takes Date a parameter and if given date is valid format then it parses otherwise it throws an error.
For Example:-Below function will return true if valid date otherwise return false.
protected bool Check_Valid_Date(String date)

{
try
{
DateTime dt = DateTime.Parse(date);

return true;
}
catch
{
return false;
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response