c# datetime parse code example

Example 1: c# string to datetime

string iDate = "05/05/2005";
DateTime oDate = Convert.ToDateTime(iDate);
MessageBox.Show(oDate.Day + " " + oDate.Month + "  " + oDate.Year );

Example 2: parse datetime c#

using System.Globalization;
DateTime.ParseExact("20200101123000", "yyyyMMddHHmmss", CultureInfo.InvariantCulture)

Example 3: c# date parse

this.Text="22/11/2009";

DateTime date = DateTime.ParseExact(this.Text, "dd/MM/yyyy", null);

Example 4: c# string to datetime

.Net str to DateTime

Tags:

Vb Example