C# Language DateTime ToString, ToShortDateString, ToLongDateString and ToString formatted


Example

using System;
                    
public class Program
{
    public static void Main()
    {
        var date = new DateTime(2016,12,31);
        
        Console.WriteLine(date.ToString());        //Outputs: 12/31/2016 12:00:00 AM
        Console.WriteLine(date.ToShortDateString()); //Outputs: 12/31/2016
        Console.WriteLine(date.ToLongDateString()); //Outputs: Saturday, December 31, 2016
        Console.WriteLine(date.ToString("dd/MM/yyyy"));    //Outputs: 31/12/2016
    }
}