/ Published in: C#
Just a small simple method I wrote in C# that's similar to Visual Basic's IsDate() function.. Inputs string date, returns boolean true/false if string is a valid date or not.
Expand |
Embed | Plain Text
public bool IsDate(string sdate) { DateTime dt; bool isDate = true; try { dt = DateTime.Parse(sdate); } catch { isDate = false; } return isDate; }
Comments
Subscribe to comments
You need to login to post a comment.

A more efficient alternative would be DateTime.TryParse (eliminates the need and overhead of try/catch).
thanks! I'm not that great of a C# coder (very very green to this language). I didn't know that method existed.