Thursday, January 14, 2010

IsDate() function in C#

C# does not provide IsDate() function, but you can build one pretty easily:

private bool IsDate(string inputDate)
{
DateTime dt;
bool isdate = DateTime.TryParse(inputDate, out dt);
return isdate;
}

You can build other functions such as IsInteger() by using int.Parse() instead of DateTime.Parse().