Check if string is date or not?

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 1421
Here is the code,
DateTime.Parse method will check whether string is date or not.If string is date then it returns true otherwise it throws an error.
public bool IsDate(string Text)
{
try
{
System.DateTime dt = System.DateTime.Parse(Text);
}
catch
{
return false;
}

return true;
}

Comments or Responses

Login to post response