CSharp examples for System:DateTime Parse
Check whether is a valid date time value.
using System.Text.RegularExpressions; using System.Text; using System.Data; using System;// ww w. j av a 2 s.c o m public class Main{ /// <summary> /// Check whether is a valid date time value. /// </summary> /// <param name="val">String value to validate</param> /// <returns>True is a valid date time otherwise false.</returns> public static bool IsDateTime(string val) { try { Convert.ToDateTime(val); return true; //Regex r = new Regex("\\d{1,2}\\/\\d{1,2}/\\d{4}"); //return r.IsMatch(val); } catch (Exception ex) { //logger.Error(ex); return false; } } }