MrMistreater

IsDate extension method for strings

May 10th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.21 KB | None | 0 0
  1. public static bool IsDate(this string sdate)
  2. {
  3.     DateTime dt;
  4.     bool isDate = true;
  5.      
  6.     try {
  7.         dt = DateTime.Parse(sdate);
  8.     }
  9.     catch {
  10.         isDate = false;
  11.     }
  12.      
  13.     return isDate;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment