string iDate = "05/05/2005";
DateTime oDate = Convert.ToDateTime(iDate);
MessageBox.Show(oDate.Day + " " + oDate.Month + " " + oDate.Year );
DateTime myDate = DateTime.ParseExact("2009-05-08 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff",
System.Globalization.CultureInfo.InvariantCulture);
DateTime convertedDate = DateTime.Parse(Date.ToString("yyyy-MM-dd"));
DateTime.TryParse(stringDate, out DateTime date);
//date variable type is DateTime
string dateInput = "1/1/2022";
DateTime date;
if ( DateTime.TryParse(dateInput, out date) ) {
Console.WriteLine("Success");
} else {
Console.WriteLine("Fail");
}