Monday, August 3, 2009

C# Check whether string is valid Date

Hi...

There are many places where we need to validate whether the given string is a valid Date or not. The following simple method handy for the same...

private bool IsDate(string strDate)

{

DateTime dt;

bool boolIsDate = true;

try

{

dt = DateTime.Parse(strDate);

}

catch

{

boolIsDate = false;

}

return boolIsDate;

}


Hope it Helpz...

4Z ~ Fauzi