c# date vs datetime code example

Example 1: c# date

using System;
class Test {
   static void Main() {
      //print current datetime
      Console.WriteLine (DateTime.Now.ToString());
      //make a custom datetime
      DateTime dt = new DateTime(2018, 7, 24);
      Console.WriteLine (dt.ToString());
   }
}

Example 2: C# date type no time

/*
There is no dedicate pure Date class because you already have DateTime which can handle it. 

If you want the standard approach look at the DateTime.Date property which gives just the date 
portion of a DateTime with the time value set to 12:00:00 midnight (00:00:00).

E.g. Console.WriteLine($"Date only: {myDateVar.Date}");
*/