DateTime - ToShortDateString

A DateTime extension method that converts this object to a short date string.

Try it

public static void Main()
{
    DateTime date = DateTime.Now;

    // C# Extension Method: DateTime - ToShortDateString
	Console.WriteLine("{0, 10} Culture {1, 40}", "Current", date.ToShortDateString());
	
	// C# Extension Method: DateTime - ToShortDateString
	Console.WriteLine("{0, 10} Culture {1, 40}", "fr-FR", date.ToShortDateString("fr-FR"));
	
	var culture = CultureInfo.CreateSpecificCulture("es-ES");
	
	// C# Extension Method: DateTime - ToShortDateString
	Console.WriteLine("{0, 10} Culture {1, 40}", culture, date.ToShortDateString(culture));
}

View Source
using System;
using System.Globalization;

public static partial class Extensions
{
    /// <summary>
    ///     A DateTime extension method that converts this object to a short date string.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>The given data converted to a string.</returns>
    public static string ToShortDateString(this DateTime @this)
    {
        return @this.ToString("d", DateTimeFormatInfo.CurrentInfo);
    }

    /// <summary>
    ///     A DateTime extension method that converts this object to a short date string.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="culture">The culture.</param>
    /// <returns>The given data converted to a string.</returns>
    public static string ToShortDateString(this DateTime @this, string culture)
    {
        return @this.ToString("d", new CultureInfo(culture));
    }

    /// <summary>
    ///     A DateTime extension method that converts this object to a short date string.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="culture">The culture.</param>
    /// <returns>The given data converted to a string.</returns>
    public static string ToShortDateString(this DateTime @this, CultureInfo culture)
    {
        return @this.ToString("d", culture);
    }
}