From 21ad0a24ea2e4605c093fc3102378a06a9552b9f Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Fri, 21 Feb 2025 16:26:03 -0800
Subject: [PATCH 1/3] Update ToString4.cs
---
.../System/DateTime/ToString/ToString4.cs | 61 ++++++++++---------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/snippets/csharp/System/DateTime/ToString/ToString4.cs b/snippets/csharp/System/DateTime/ToString/ToString4.cs
index f767dde6e5a..2667e1ceecd 100644
--- a/snippets/csharp/System/DateTime/ToString/ToString4.cs
+++ b/snippets/csharp/System/DateTime/ToString/ToString4.cs
@@ -1,38 +1,39 @@
-//
-using System;
using System.Globalization;
public class ToStringExample3
{
- public static void Main2()
- {
- CultureInfo[] cultures = new CultureInfo[] {CultureInfo.InvariantCulture,
- new CultureInfo("en-us"),
- new CultureInfo("fr-fr"),
- new CultureInfo("de-DE"),
- new CultureInfo("es-ES"),
- new CultureInfo("ja-JP")};
+ public static void Main()
+ {
+ //
+ CultureInfo[] cultures = [
+ CultureInfo.InvariantCulture,
+ new CultureInfo("en-us"),
+ new CultureInfo("fr-fr"),
+ new CultureInfo("de-DE"),
+ new CultureInfo("es-ES"),
+ new CultureInfo("ja-JP")
+ ];
- DateTime thisDate = new DateTime(2009, 5, 1, 9, 0, 0);
+ DateTime thisDate = new(2025, 5, 1, 9, 0, 0);
- foreach (CultureInfo culture in cultures)
- {
- string cultureName;
- if (string.IsNullOrEmpty(culture.Name))
- cultureName = culture.NativeName;
- else
- cultureName = culture.Name;
+ foreach (CultureInfo culture in cultures)
+ {
+ string cultureName;
+ if (string.IsNullOrEmpty(culture.Name))
+ cultureName = culture.NativeName;
+ else
+ cultureName = culture.Name;
- Console.WriteLine("In {0}, {1}",
- cultureName, thisDate.ToString(culture));
- }
- }
+ 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
-//
From 6543e727c304789bab02c4aedc89b6a59c64935f Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Fri, 21 Feb 2025 17:08:39 -0800
Subject: [PATCH 2/3] fix compilation
---
snippets/csharp/System/DateTime/ToString/ToString4.cs | 1 +
snippets/csharp/System/DateTime/ToString/tostring.csproj | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/snippets/csharp/System/DateTime/ToString/ToString4.cs b/snippets/csharp/System/DateTime/ToString/ToString4.cs
index 2667e1ceecd..e9f2cb14da3 100644
--- a/snippets/csharp/System/DateTime/ToString/ToString4.cs
+++ b/snippets/csharp/System/DateTime/ToString/ToString4.cs
@@ -1,3 +1,4 @@
+using System;
using System.Globalization;
public class ToStringExample3
diff --git a/snippets/csharp/System/DateTime/ToString/tostring.csproj b/snippets/csharp/System/DateTime/ToString/tostring.csproj
index c645c6b0fbb..0db7a648e12 100644
--- a/snippets/csharp/System/DateTime/ToString/tostring.csproj
+++ b/snippets/csharp/System/DateTime/ToString/tostring.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net9.0
enable
MainClass
From a59f42273d7db9d47a596df58a326e14ba26476b Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Mon, 24 Feb 2025 08:46:10 -0800
Subject: [PATCH 3/3] Update
snippets/csharp/System/DateTime/ToString/ToString4.cs
---
snippets/csharp/System/DateTime/ToString/ToString4.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/snippets/csharp/System/DateTime/ToString/ToString4.cs b/snippets/csharp/System/DateTime/ToString/ToString4.cs
index e9f2cb14da3..43251ca60a5 100644
--- a/snippets/csharp/System/DateTime/ToString/ToString4.cs
+++ b/snippets/csharp/System/DateTime/ToString/ToString4.cs
@@ -13,7 +13,7 @@ public static void Main()
new CultureInfo("de-DE"),
new CultureInfo("es-ES"),
new CultureInfo("ja-JP")
- ];
+ ];
DateTime thisDate = new(2025, 5, 1, 9, 0, 0);