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