From e7311356a20f129e51f5abb250e074d0fec4ba8b Mon Sep 17 00:00:00 2001 From: Stuart Mosquera Date: Fri, 26 Sep 2025 11:03:20 -0300 Subject: [PATCH] fix 'ToString' method example display --- .../System/DateTime/ToString/ToString4.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/snippets/csharp/System/DateTime/ToString/ToString4.cs b/snippets/csharp/System/DateTime/ToString/ToString4.cs index 43251ca60a5..4998c1d71fa 100644 --- a/snippets/csharp/System/DateTime/ToString/ToString4.cs +++ b/snippets/csharp/System/DateTime/ToString/ToString4.cs @@ -1,11 +1,11 @@ -using System; +// +using System; using System.Globalization; public class ToStringExample3 { public static void Main() { - // CultureInfo[] cultures = [ CultureInfo.InvariantCulture, new CultureInfo("en-us"), @@ -20,6 +20,7 @@ public static void Main() foreach (CultureInfo culture in cultures) { string cultureName; + if (string.IsNullOrEmpty(culture.Name)) cultureName = culture.NativeName; else @@ -27,14 +28,14 @@ public static void Main() Console.WriteLine($"In {cultureName}, {thisDate.ToString(culture)}"); } - - // The example produces the following output: - // In Invariant Language (Invariant Country), 05/01/2009 09:00:00 - // In en-US, 5/1/2009 9:00:00 AM - // In fr-FR, 01/05/2009 09:00:00 - // In de-DE, 01.05.2009 09:00:00 - // In es-ES, 01/05/2009 9:00:00 - // In ja-JP, 2009/05/01 9:00:00 - // } } + +// The example produces the following output: +// In Invariant Language (Invariant Country), 05/01/2009 09:00:00 +// In en-US, 5/1/2009 9:00:00 AM +// In fr-FR, 01/05/2009 09:00:00 +// In de-DE, 01.05.2009 09:00:00 +// In es-ES, 01/05/2009 9:00:00 +// In ja-JP, 2009/05/01 9:00:00 +//