Get Valid Date from String - CSharp System

CSharp examples for System:DateTime Format

Description

Get Valid Date from String

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//w  w w.j a v a 2s.  c o m

public class Main{
        public static DateTime GetValidDate(this string value)
        {
            DateTime temp;
            if (DateTime.TryParse(value, out temp)) return temp;

            return new DateTime(1900, 1, 1);
        }
}

Related Tutorials