public static class StaticParameters
public static string ToShortDate(DateTime? date)
if (date == null || !date.HasValue) return "";
return date.Value.ToShortDateString();
public static class DateTimeExtensions
public static string ToShortDate(this DateTime? date)
if (date == null || !date.HasValue) { return ""; }
return date.Value.ToShortDateString();
public static class Format
public static string FormatWithArgOrEmpty(string s, string arg0)
if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(arg0)) return "";
return string.Format(s, arg0);
public static void Main()
DateTime? NextDate = null;
string nextDate_Un = Format.FormatWithArgOrEmpty("Prochain départ le {0}", StaticParameters.ToShortDate(NextDate));
string nextDate_Deux = Format.FormatWithArgOrEmpty("Prochain départ le {0}", NextDate.ToShortDate());
Console.WriteLine("Début");
Console.WriteLine(nextDate_Un);
Console.WriteLine(nextDate_Deux);
Console.WriteLine("Fin");