From 77bb946fcb8c16c8dad9acee4d8f3b71a175d1c2 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Wed, 3 Jun 2026 21:05:25 -0700
Subject: [PATCH 1/8] Reinstate supplemental remarks
---
.../CultureInfo/CurrentCulture/Async1.cs | 39 ++
.../CultureInfo/CurrentCulture/Get1.cs | 15 +
.../CultureInfo/CurrentCulture/Project.csproj | 8 +
.../CurrentCulture/aspculture13.cs | 20 +
.../CurrentCulture/changeculture11.cs | 33 ++
.../CultureInfo/CurrentCulture/specific12.cs | 26 ++
.../CultureInfo/CurrentUICulture/Async1.cs | 39 ++
.../CultureInfo/CurrentUICulture/Get1.cs | 15 +
.../CurrentUICulture/Project.csproj | 8 +
.../CurrentUICulture/currentuiculture1.cs | 18 +
.../CultureInfo/InvariantCulture/persist1.cs | 50 +++
.../DateTimeFormatInfo/create1.cs | 112 +++++
.../DateTimeFormatInfo/create2.cs | 25 ++
.../DateTimeFormatInfo/example1.cs | 28 ++
.../DateTimeFormatInfo/example2.cs | 39 ++
.../DateTimeFormatInfo/example3.cs | 23 +
.../DateTimeFormatInfo/example4.cs | 47 +++
.../DateTimeFormatInfo/example5.cs | 47 +++
.../DateTimeFormatInfo/formatprovider1.cs | 42 ++
.../DateTimeFormatInfo/instantiate2.cs | 21 +
.../DateTimeFormatInfo/instantiate3.cs | 32 ++
.../DateTimeFormatInfo/instantiate6.cs | 119 ++++++
.../DateTimeFormatInfo/parse1.cs | 45 ++
.../DateTimeFormatInfo/parse2.cs | 36 ++
.../DateTimeFormatInfo/project.csproj | 9 +
.../DateTimeFormatInfo/serialize1.cs | 28 ++
.../DateTimeFormatInfo/serialize2.cs | 29 ++
.../CultureInfo/CurrentCulture/Async1.vb | 42 ++
.../CultureInfo/CurrentCulture/Get1.vb | 16 +
.../CultureInfo/CurrentCulture/Program.vb | 5 +
.../CultureInfo/CurrentCulture/Project.vbproj | 8 +
.../CurrentCulture/aspculture13.vb | 23 +
.../CurrentCulture/changeculture11.vb | 35 ++
.../CultureInfo/CurrentCulture/specific12.vb | 30 ++
.../CultureInfo/CurrentUICulture/Async1.vb | 42 ++
.../CultureInfo/CurrentUICulture/Get1.vb | 16 +
.../CurrentUICulture/Project.vbproj | 8 +
.../CurrentUICulture/currentuiculture1.vb | 20 +
.../InvariantCulture/Project.vbproj | 8 +
.../CultureInfo/InvariantCulture/persist1.vb | 53 +++
xml/System.Globalization/CompareInfo.xml | 26 +-
xml/System.Globalization/CompareOptions.xml | 12 +-
xml/System.Globalization/CultureInfo.xml | 396 +++++++++++++++++-
.../DateTimeFormatInfo.xml | 359 +++++++++++++++-
xml/System.Globalization/NumberFormatInfo.xml | 226 +++++++++-
xml/System.Globalization/PersianCalendar.xml | 33 +-
xml/System.Globalization/RegionInfo.xml | 30 +-
xml/System.Globalization/SortKey.xml | 43 +-
xml/System.Globalization/SortVersion.xml | 43 +-
xml/System.IO/FileStream.xml | 34 +-
xml/System.IO/FileSystemWatcher.xml | 49 ++-
51 files changed, 2491 insertions(+), 19 deletions(-)
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Async1.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Get1.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Project.csproj
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/aspculture13.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/changeculture11.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/specific12.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Async1.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Get1.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Project.csproj
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.cs
create mode 100644 snippets/csharp/System.Globalization/CultureInfo/InvariantCulture/persist1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/create2.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/example1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/example2.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/example3.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/example4.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/example5.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/formatprovider1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate2.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate3.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate6.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/parse1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/parse2.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/project.csproj
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize1.cs
create mode 100644 snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize2.cs
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Async1.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Get1.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Program.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Project.vbproj
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/aspculture13.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/changeculture11.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/specific12.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Async1.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Get1.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Project.vbproj
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.vb
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/Project.vbproj
create mode 100644 snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/persist1.vb
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Async1.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Async1.cs
new file mode 100644
index 00000000000..862b15bbfd7
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Async1.cs
@@ -0,0 +1,39 @@
+//
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Runtime.Versioning;
+using System.Threading;
+using System.Threading.Tasks;
+
+public class Example14
+{
+ public static async Task Main()
+ {
+ var tasks = new List();
+ Console.WriteLine($"The current culture is {Thread.CurrentThread.CurrentCulture.Name}");
+ Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR");
+ // Change the current culture to Portuguese (Brazil).
+ Console.WriteLine($"Current culture changed to {Thread.CurrentThread.CurrentCulture.Name}");
+ Console.WriteLine($"Application thread is thread {Thread.CurrentThread.ManagedThreadId}");
+ // Launch six tasks and display their current culture.
+ for (int ctr = 0; ctr <= 5; ctr++)
+ tasks.Add(Task.Run(() =>
+ {
+ Console.WriteLine($"Culture of task {Task.CurrentId} on thread {Thread.CurrentThread.ManagedThreadId} is {Thread.CurrentThread.CurrentCulture.Name}");
+ }));
+
+ await Task.WhenAll(tasks.ToArray());
+ }
+}
+// The example displays output like the following:
+// The current culture is en-US
+// Current culture changed to pt-BR
+// Application thread is thread 9
+// Culture of task 2 on thread 11 is pt-BR
+// Culture of task 1 on thread 10 is pt-BR
+// Culture of task 3 on thread 11 is pt-BR
+// Culture of task 5 on thread 11 is pt-BR
+// Culture of task 6 on thread 11 is pt-BR
+// Culture of task 4 on thread 10 is pt-BR
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Get1.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Get1.cs
new file mode 100644
index 00000000000..f07ebd7151e
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Get1.cs
@@ -0,0 +1,15 @@
+//
+using System;
+using System.Globalization;
+
+public class Example5
+{
+ public static void Main()
+ {
+ CultureInfo culture = CultureInfo.CurrentCulture;
+ Console.WriteLine($"The current culture is {culture.NativeName} [{culture.Name}]");
+ }
+}
+// The example displays output like the following:
+// The current culture is English (United States) [en-US]
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Project.csproj b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Project.csproj
new file mode 100644
index 00000000000..874c98f3477
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Project.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Library
+ net10.0
+
+
+
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/aspculture13.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/aspculture13.cs
new file mode 100644
index 00000000000..f35caeb4dc8
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/aspculture13.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Globalization;
+using System.Threading;
+
+public class Example13
+{
+ public static void Main()
+ {
+ //
+ CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(Request13.UserLanguages[0]);
+ //
+ }
+}
+
+public class Request13
+{
+ private static string[] langs = new string[3];
+
+ public static string[] UserLanguages { get { return langs; } }
+}
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/changeculture11.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/changeculture11.cs
new file mode 100644
index 00000000000..699931f4242
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/changeculture11.cs
@@ -0,0 +1,33 @@
+//
+using System;
+using System.Globalization;
+using System.Threading;
+
+public class Info11 : MarshalByRefObject
+{
+ public void ShowCurrentCulture()
+ {
+ Console.WriteLine($"Culture of {Thread.CurrentThread.Name} in application domain {AppDomain.CurrentDomain.FriendlyName}: {CultureInfo.CurrentCulture.Name}");
+ }
+}
+
+public class Example11
+{
+ public static void Main()
+ {
+ Info11 inf = new Info11();
+ // Set the current culture to Dutch (Netherlands).
+ Thread.CurrentThread.Name = "MainThread";
+ CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL");
+ inf.ShowCurrentCulture();
+
+ // Create a new application domain.
+ AppDomain ad = AppDomain.CreateDomain("Domain2");
+ Info11 inf2 = (Info11)ad.CreateInstanceAndUnwrap(typeof(Info11).Assembly.FullName, "Info11");
+ inf2.ShowCurrentCulture();
+ }
+}
+// The example displays the following output:
+// Culture of MainThread in application domain ChangeCulture1.exe: nl-NL
+// Culture of MainThread in application domain Domain2: nl-NL
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/specific12.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/specific12.cs
new file mode 100644
index 00000000000..85f7b6e54eb
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/specific12.cs
@@ -0,0 +1,26 @@
+//
+using System;
+using System.Globalization;
+using System.Threading;
+
+public class Example12
+{
+ public static void Main()
+ {
+ double value = 1634.92;
+ CultureInfo.CurrentCulture = new CultureInfo("fr-CA");
+ Console.WriteLine($"Current Culture: {CultureInfo.CurrentCulture.Name}");
+ Console.WriteLine($"{value:C2}\n");
+
+ Thread.CurrentThread.CurrentCulture = new CultureInfo("fr");
+ Console.WriteLine($"Current Culture: {CultureInfo.CurrentCulture.Name}");
+ Console.WriteLine($"{value:C2}");
+ }
+}
+// The example displays the following output:
+// Current Culture: fr-CA
+// 1 634,92 $
+//
+// Current Culture: fr
+// 1 634,92 €
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Async1.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Async1.cs
new file mode 100644
index 00000000000..37fc0573971
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Async1.cs
@@ -0,0 +1,39 @@
+//
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Runtime.Versioning;
+using System.Threading;
+using System.Threading.Tasks;
+
+public class Example
+{
+ public static async Task Main()
+ {
+ var tasks = new List();
+ Console.WriteLine($"The current UI culture is {Thread.CurrentThread.CurrentUICulture.Name}");
+ Thread.CurrentThread.CurrentUICulture = new CultureInfo("pt-BR");
+ // Change the current UI culture to Portuguese (Brazil).
+ Console.WriteLine($"Current UI culture changed to {Thread.CurrentThread.CurrentUICulture.Name}");
+ Console.WriteLine($"Application thread is thread {Thread.CurrentThread.ManagedThreadId}");
+ // Launch six tasks and display their current culture.
+ for (int ctr = 0; ctr <= 5; ctr++)
+ tasks.Add(Task.Run(() =>
+ {
+ Console.WriteLine($"UI Culture of task {Task.CurrentId} on thread {Thread.CurrentThread.ManagedThreadId} is {Thread.CurrentThread.CurrentUICulture.Name}");
+ }));
+
+ await Task.WhenAll(tasks.ToArray());
+ }
+}
+// The example displays output like the following:
+// The current UI culture is en-US
+// Current UI culture changed to pt-BR
+// Application thread is thread 9
+// UI Culture of task 2 on thread 11 is pt-BR
+// UI Culture of task 1 on thread 10 is pt-BR
+// UI Culture of task 3 on thread 11 is pt-BR
+// UI Culture of task 5 on thread 11 is pt-BR
+// UI Culture of task 6 on thread 11 is pt-BR
+// UI Culture of task 4 on thread 10 is pt-BR
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Get1.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Get1.cs
new file mode 100644
index 00000000000..62eb67f1b7d
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Get1.cs
@@ -0,0 +1,15 @@
+//
+using System;
+using System.Globalization;
+
+public class Example2
+{
+ public static void Main()
+ {
+ CultureInfo culture = CultureInfo.CurrentUICulture;
+ Console.WriteLine($"The current UI culture is {culture.NativeName} [{culture.Name}]");
+ }
+}
+// The example displays output like the following:
+// The current UI culture is English (United States) [en-US]
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Project.csproj b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Project.csproj
new file mode 100644
index 00000000000..874c98f3477
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Project.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Library
+ net10.0
+
+
+
diff --git a/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.cs b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.cs
new file mode 100644
index 00000000000..8c1432d7829
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.cs
@@ -0,0 +1,18 @@
+//
+using System;
+using System.Globalization;
+
+public class Example1
+{
+ public static void Main()
+ {
+ Console.WriteLine($"The current UI culture: {CultureInfo.CurrentUICulture.Name}");
+
+ CultureInfo.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr-FR");
+ Console.WriteLine($"The current UI culture: {CultureInfo.CurrentUICulture.Name}");
+ }
+}
+// The example displays output like the following:
+// The current UI culture: en-US
+// The current UI culture: fr-FR
+//
diff --git a/snippets/csharp/System.Globalization/CultureInfo/InvariantCulture/persist1.cs b/snippets/csharp/System.Globalization/CultureInfo/InvariantCulture/persist1.cs
new file mode 100644
index 00000000000..9d21620ea6a
--- /dev/null
+++ b/snippets/csharp/System.Globalization/CultureInfo/InvariantCulture/persist1.cs
@@ -0,0 +1,50 @@
+//
+using System;
+using System.IO;
+using System.Globalization;
+
+public class Example
+{
+ public static void Main()
+ {
+ // Persist the date and time data.
+ StreamWriter sw = new StreamWriter(@".\DateData.dat");
+
+ // Create a DateTime value.
+ DateTime dtIn = DateTime.Now;
+ // Retrieve a CultureInfo object.
+ CultureInfo invC = CultureInfo.InvariantCulture;
+
+ // Convert the date to a string and write it to a file.
+ sw.WriteLine(dtIn.ToString("r", invC));
+ sw.Close();
+
+ // Restore the date and time data.
+ StreamReader sr = new StreamReader(@".\DateData.dat");
+ String input;
+ while ((input = sr.ReadLine()) != null)
+ {
+ Console.WriteLine($"Stored data: {input}\n");
+
+ // Parse the stored string.
+ DateTime dtOut = DateTime.Parse(input, invC, DateTimeStyles.RoundtripKind);
+
+ // Create a French (France) CultureInfo object.
+ CultureInfo frFr = new CultureInfo("fr-FR");
+ // Displays the date formatted for the "fr-FR" culture.
+ Console.WriteLine($"Date formatted for the {frFr.Name} culture: {dtOut.ToString("f", frFr)}");
+
+ // Creates a German (Germany) CultureInfo object.
+ CultureInfo deDe= new CultureInfo("de-De");
+ // Displays the date formatted for the "de-DE" culture.
+ Console.WriteLine($"Date formatted for {deDe.Name} culture: {dtOut.ToString("f", deDe)}");
+ }
+ sr.Close();
+ }
+}
+// The example displays the following output:
+// Stored data: Tue, 15 May 2012 16:34:16 GMT
+//
+// Date formatted for the fr-FR culture: mardi 15 mai 2012 16:34
+// Date formatted for de-DE culture: Dienstag, 15. Mai 2012 16:34
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs
new file mode 100644
index 00000000000..9c54c076ec0
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs
@@ -0,0 +1,112 @@
+using System;
+
+public class Example
+{
+ public static void Main()
+ {
+ CreateInvariant1();
+ Console.WriteLine();
+ CreateNeutral2();
+ Console.WriteLine();
+ CreateSpecific3();
+ }
+
+ private static void CreateInvariant1()
+ {
+ //
+ System.Globalization.DateTimeFormatInfo dtfi;
+
+ dtfi = System.Globalization.DateTimeFormatInfo.InvariantInfo;
+ Console.WriteLine(dtfi.IsReadOnly);
+
+ dtfi = new System.Globalization.DateTimeFormatInfo();
+ Console.WriteLine(dtfi.IsReadOnly);
+
+ dtfi = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat;
+ Console.WriteLine(dtfi.IsReadOnly);
+ // The example displays the following output:
+ // True
+ // False
+ // True
+ //
+ }
+
+ private static void CreateNeutral2()
+ {
+ //
+ System.Globalization.CultureInfo specific, neutral;
+ System.Globalization.DateTimeFormatInfo dtfi;
+
+ // Instantiate a culture by creating a specific culture and using its Parent property.
+ specific = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
+ neutral = specific.Parent;
+ dtfi = neutral.DateTimeFormat;
+ Console.WriteLine($"{neutral.Name} from Parent property: {dtfi.IsReadOnly}");
+
+ dtfi = System.Globalization.CultureInfo.GetCultureInfo("fr-FR").Parent.DateTimeFormat;
+ Console.WriteLine($"{neutral.Name} from Parent property: {dtfi.IsReadOnly}");
+
+ // Instantiate a neutral culture using the CultureInfo constructor.
+ neutral = new System.Globalization.CultureInfo("fr");
+ dtfi = neutral.DateTimeFormat;
+ Console.WriteLine($"{neutral.Name} from CultureInfo constructor: {dtfi.IsReadOnly}");
+
+ // Instantiate a culture using CreateSpecificCulture.
+ neutral = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
+ dtfi = neutral.DateTimeFormat;
+ Console.WriteLine($"{neutral.Name} from CreateSpecificCulture: {dtfi.IsReadOnly}");
+
+ // Retrieve a culture by calling the GetCultureInfo method.
+ neutral = System.Globalization.CultureInfo.GetCultureInfo("fr");
+ dtfi = neutral.DateTimeFormat;
+ Console.WriteLine($"{neutral.Name} from GetCultureInfo: {dtfi.IsReadOnly}");
+
+ // Instantiate a DateTimeFormatInfo object by calling GetInstance.
+ neutral = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
+ dtfi = System.Globalization.DateTimeFormatInfo.GetInstance(neutral);
+ Console.WriteLine($"{neutral.Name} from GetInstance: {dtfi.IsReadOnly}");
+
+ // The example displays the following output:
+ // fr from Parent property: False
+ // fr from Parent property: False
+ // fr from CultureInfo constructor: False
+ // fr-FR from CreateSpecificCulture: False
+ // fr from GetCultureInfo: True
+ // fr-FR from GetInstance: False
+ //
+ }
+
+ private static void CreateSpecific3()
+ {
+ //
+ System.Globalization.CultureInfo ci = null;
+ System.Globalization.DateTimeFormatInfo dtfi = null;
+
+ // Instantiate a culture using CreateSpecificCulture.
+ ci = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
+ dtfi = ci.DateTimeFormat;
+ Console.WriteLine($"{ci.Name} from CreateSpecificCulture: {dtfi.IsReadOnly}");
+
+ // Instantiate a culture using the CultureInfo constructor.
+ ci = new System.Globalization.CultureInfo("en-CA");
+ dtfi = ci.DateTimeFormat;
+ Console.WriteLine($"{ci.Name} from CultureInfo constructor: {dtfi.IsReadOnly}");
+
+ // Retrieve a culture by calling the GetCultureInfo method.
+ ci = System.Globalization.CultureInfo.GetCultureInfo("en-AU");
+ dtfi = ci.DateTimeFormat;
+ Console.WriteLine($"{ci.Name} from GetCultureInfo: {dtfi.IsReadOnly}");
+
+ // Instantiate a DateTimeFormatInfo object by calling DateTimeFormatInfo.GetInstance.
+ ci = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
+ dtfi = System.Globalization.DateTimeFormatInfo.GetInstance(ci);
+ Console.WriteLine($"{ci.Name} from GetInstance: {dtfi.IsReadOnly}");
+
+ // The example displays the following output:
+ // en-US from CreateSpecificCulture: False
+ // en-CA from CultureInfo constructor: False
+ // en-AU from GetCultureInfo: True
+ // en-GB from GetInstance: False
+ //
+ }
+}
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/create2.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/create2.cs
new file mode 100644
index 00000000000..01e02d14e15
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/create2.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Globalization;
+
+public class Create2Ex
+{
+ public static void Main()
+ {
+ //
+ DateTimeFormatInfo dtfi;
+
+ dtfi = DateTimeFormatInfo.CurrentInfo;
+ Console.WriteLine(dtfi.IsReadOnly);
+
+ dtfi = CultureInfo.CurrentCulture.DateTimeFormat;
+ Console.WriteLine(dtfi.IsReadOnly);
+
+ dtfi = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture);
+ Console.WriteLine(dtfi.IsReadOnly);
+ // The example displays the following output:
+ // True
+ // True
+ // True
+ //
+ }
+}
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/example1.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example1.cs
new file mode 100644
index 00000000000..329b9ee31e8
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example1.cs
@@ -0,0 +1,28 @@
+//
+using System;
+using System.Globalization;
+
+public class Example1
+{
+ public static void Main()
+ {
+ DateTime dateValue = new DateTime(2013, 8, 18);
+ CultureInfo enUS = CultureInfo.CreateSpecificCulture("en-US");
+ DateTimeFormatInfo dtfi = enUS.DateTimeFormat;
+
+ Console.WriteLine("Before modifying DateTimeFormatInfo object: ");
+ Console.WriteLine($"{dtfi.ShortDatePattern}: {dateValue.ToString("d", enUS)}\n");
+
+ // Modify the short date pattern.
+ dtfi.ShortDatePattern = "yyyy-MM-dd";
+ Console.WriteLine("After modifying DateTimeFormatInfo object: ");
+ Console.WriteLine($"{dtfi.ShortDatePattern}: {dateValue.ToString("d", enUS)}");
+ }
+}
+// The example displays the following output:
+// Before modifying DateTimeFormatInfo object:
+// M/d/yyyy: 8/18/2013
+//
+// After modifying DateTimeFormatInfo object:
+// yyyy-MM-dd: 2013-08-18
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/example2.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example2.cs
new file mode 100644
index 00000000000..3ff54e26a15
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example2.cs
@@ -0,0 +1,39 @@
+//
+using System;
+using System.Globalization;
+
+public class Example2
+{
+ public static void Main()
+ {
+ DateTime value = new DateTime(2013, 7, 9);
+ CultureInfo enUS = CultureInfo.CreateSpecificCulture("en-US");
+ DateTimeFormatInfo dtfi = enUS.DateTimeFormat;
+ String[] formats = { "D", "F", "f" };
+
+ // Display date before modifying properties.
+ foreach (var fmt in formats)
+ Console.WriteLine($"{fmt}: {value.ToString(fmt, dtfi)}");
+
+ Console.WriteLine();
+
+ // We don't want to change the FullDateTimePattern, so we need to save it.
+ String originalFullDateTimePattern = dtfi.FullDateTimePattern;
+
+ // Modify day name abbreviations and long date pattern.
+ dtfi.AbbreviatedDayNames = new String[] { "Su", "M", "Tu", "W", "Th", "F", "Sa" };
+ dtfi.LongDatePattern = "ddd dd-MMM-yyyy";
+ dtfi.FullDateTimePattern = originalFullDateTimePattern;
+ foreach (var fmt in formats)
+ Console.WriteLine($"{fmt}: {value.ToString(fmt, dtfi)}");
+ }
+}
+// The example displays the following output:
+// D: Tuesday, July 9, 2013
+// F: Tuesday, July 9, 2013 12:00:00 AM
+// f: Tuesday, July 9, 2013 12:00 AM
+//
+// D: Tu 09-Jul-2013
+// F: Tuesday, July 9, 2013 12:00:00 AM
+// f: Tu 09-Jul-2013 12:00 AM
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/example3.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example3.cs
new file mode 100644
index 00000000000..925227609f5
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example3.cs
@@ -0,0 +1,23 @@
+//
+using System;
+using System.Globalization;
+
+public class Example3
+{
+ public static void Main()
+ {
+ DateTime dateValue = new DateTime(2013, 08, 28);
+ CultureInfo frFR = CultureInfo.CreateSpecificCulture("fr-FR");
+ DateTimeFormatInfo dtfi = frFR.DateTimeFormat;
+
+ Console.WriteLine($"Before modifying DateSeparator property: {dateValue.ToString("g", frFR)}");
+
+ // Modify the date separator.
+ dtfi.DateSeparator = "-";
+ Console.WriteLine($"After modifying the DateSeparator property: {dateValue.ToString("g", frFR)}");
+ }
+}
+// The example displays the following output:
+// Before modifying DateSeparator property: 28/08/2013 00:00
+// After modifying the DateSeparator property: 28-08-2013 00:00
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/example4.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example4.cs
new file mode 100644
index 00000000000..14f4fc81404
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example4.cs
@@ -0,0 +1,47 @@
+//
+using System;
+using System.Globalization;
+
+public class Example4
+{
+ public static void Main()
+ {
+ DateTime dateValue = new DateTime(2013, 5, 18, 13, 30, 0);
+ String[] formats = { "D", "f", "F" };
+
+ CultureInfo enUS = CultureInfo.CreateSpecificCulture("en-US");
+ DateTimeFormatInfo dtfi = enUS.DateTimeFormat;
+ String originalLongDatePattern = dtfi.LongDatePattern;
+
+ // Display the default form of three long date formats.
+ foreach (var fmt in formats)
+ Console.WriteLine(dateValue.ToString(fmt, dtfi));
+
+ Console.WriteLine();
+
+ // Modify the long date pattern.
+ dtfi.LongDatePattern = originalLongDatePattern + " g";
+ foreach (var fmt in formats)
+ Console.WriteLine(dateValue.ToString(fmt, dtfi));
+
+ Console.WriteLine();
+
+ // Change A.D. to C.E. (for Common Era)
+ dtfi.LongDatePattern = originalLongDatePattern + @" 'C.E.'";
+ foreach (var fmt in formats)
+ Console.WriteLine(dateValue.ToString(fmt, dtfi));
+ }
+}
+// The example displays the following output:
+// Saturday, May 18, 2013
+// Saturday, May 18, 2013 1:30 PM
+// Saturday, May 18, 2013 1:30:00 PM
+//
+// Saturday, May 18, 2013 A.D.
+// Saturday, May 18, 2013 A.D. 1:30 PM
+// Saturday, May 18, 2013 A.D. 1:30:00 PM
+//
+// Saturday, May 18, 2013 C.E.
+// Saturday, May 18, 2013 C.E. 1:30 PM
+// Saturday, May 18, 2013 C.E. 1:30:00 PM
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/example5.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example5.cs
new file mode 100644
index 00000000000..e23c4454dad
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/example5.cs
@@ -0,0 +1,47 @@
+//
+using System;
+using System.Globalization;
+using System.Text.RegularExpressions;
+
+public class Example5
+{
+ public static void Main()
+ {
+ CultureInfo enUS = CultureInfo.CreateSpecificCulture("en-US");
+ DateTimeFormatInfo dtfi = enUS.DateTimeFormat;
+
+ Console.WriteLine("Original Property Values:");
+ Console.WriteLine("ShortTimePattern: " + dtfi.ShortTimePattern);
+ Console.WriteLine("LongTimePattern: " + dtfi.LongTimePattern);
+ Console.WriteLine("FullDateTimePattern: " + dtfi.FullDateTimePattern);
+ Console.WriteLine();
+
+ dtfi.LongTimePattern = ReplaceWith24HourClock(dtfi.LongTimePattern);
+ dtfi.ShortTimePattern = ReplaceWith24HourClock(dtfi.ShortTimePattern);
+
+ Console.WriteLine("Modififed Property Values:");
+ Console.WriteLine("ShortTimePattern: " + dtfi.ShortTimePattern);
+ Console.WriteLine("LongTimePattern: " + dtfi.LongTimePattern);
+ Console.WriteLine("FullDateTimePattern: " + dtfi.FullDateTimePattern);
+ }
+
+ private static string ReplaceWith24HourClock(string fmt)
+ {
+ string pattern = @"^(?\s*t+\s*)? " +
+ @"(?(openAMPM) h+(?[^ht]+)$ " +
+ @"| \s*h+(?[^ht]+)\s*t+)";
+ return Regex.Replace(fmt, pattern, "HH${nonHours}",
+ RegexOptions.IgnorePatternWhitespace);
+ }
+}
+// The example displays the following output:
+// Original Property Values:
+// ShortTimePattern: h:mm tt
+// LongTimePattern: h:mm:ss tt
+// FullDateTimePattern: dddd, MMMM dd, yyyy h:mm:ss tt
+//
+// Modififed Property Values:
+// ShortTimePattern: HH:mm
+// LongTimePattern: HH:mm:ss
+// FullDateTimePattern: dddd, MMMM dd, yyyy HH:mm:ss
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/formatprovider1.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/formatprovider1.cs
new file mode 100644
index 00000000000..1cdaa7e5fd9
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/formatprovider1.cs
@@ -0,0 +1,42 @@
+//
+using System;
+using System.Globalization;
+
+public class CurrentCultureFormatProvider : IFormatProvider
+{
+ public Object GetFormat(Type formatType)
+ {
+ Console.WriteLine($"Requesting an object of type {formatType.Name}");
+ if (formatType == typeof(NumberFormatInfo))
+ return NumberFormatInfo.CurrentInfo;
+ else if (formatType == typeof(DateTimeFormatInfo))
+ return DateTimeFormatInfo.CurrentInfo;
+ else
+ return null;
+ }
+}
+
+public class FormatProviderEx1
+{
+ public static void Main()
+ {
+ DateTime dateValue = new DateTime(2013, 5, 28, 13, 30, 0);
+ string value = dateValue.ToString("F", new CurrentCultureFormatProvider());
+ Console.WriteLine(value);
+ Console.WriteLine();
+ string composite = String.Format(new CurrentCultureFormatProvider(),
+ "Date: {0:d} Amount: {1:C} Description: {2}",
+ dateValue, 1264.03m, "Service Charge");
+ Console.WriteLine(composite);
+ Console.WriteLine();
+ }
+}
+// The example displays output like the following:
+// Requesting an object of type DateTimeFormatInfo
+// Tuesday, May 28, 2013 1:30:00 PM
+//
+// Requesting an object of type ICustomFormatter
+// Requesting an object of type DateTimeFormatInfo
+// Requesting an object of type NumberFormatInfo
+// Date: 5/28/2013 Amount: $1,264.03 Description: Service Charge
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate2.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate2.cs
new file mode 100644
index 00000000000..fde2e0a0c06
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate2.cs
@@ -0,0 +1,21 @@
+//
+using System;
+using System.Globalization;
+
+public class InstantiateEx1
+{
+ public static void Main()
+ {
+ DateTimeFormatInfo current1 = DateTimeFormatInfo.CurrentInfo;
+ current1 = (DateTimeFormatInfo)current1.Clone();
+ Console.WriteLine(current1.IsReadOnly);
+
+ CultureInfo culture2 = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);
+ DateTimeFormatInfo current2 = culture2.DateTimeFormat;
+ Console.WriteLine(current2.IsReadOnly);
+ }
+}
+// The example displays the following output:
+// False
+// False
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate3.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate3.cs
new file mode 100644
index 00000000000..5eb266248b6
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate3.cs
@@ -0,0 +1,32 @@
+//
+using System;
+using System.Globalization;
+
+public class InstantiateEx3
+{
+ public static void Main()
+ {
+ CultureInfo culture;
+ DateTimeFormatInfo dtfi;
+
+ culture = CultureInfo.CurrentCulture;
+ dtfi = culture.DateTimeFormat;
+ Console.WriteLine($"Culture Name: {culture.Name}");
+ Console.WriteLine($"User Overrides: {culture.UseUserOverride}");
+ Console.WriteLine($"Long Time Pattern: {culture.DateTimeFormat.LongTimePattern}\n");
+
+ culture = new CultureInfo(CultureInfo.CurrentCulture.Name, false);
+ Console.WriteLine($"Culture Name: {culture.Name}");
+ Console.WriteLine($"User Overrides: {culture.UseUserOverride}");
+ Console.WriteLine($"Long Time Pattern: {culture.DateTimeFormat.LongTimePattern}\n");
+ }
+}
+// The example displays the following output:
+// Culture Name: en-US
+// User Overrides: True
+// Long Time Pattern: HH:mm:ss
+//
+// Culture Name: en-US
+// User Overrides: False
+// Long Time Pattern: h:mm:ss tt
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate6.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate6.cs
new file mode 100644
index 00000000000..2a1235fde35
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate6.cs
@@ -0,0 +1,119 @@
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+
+public class InstantiateEx6
+{
+ public static void Main()
+ {
+ // Get all the neutral cultures
+ List names = new List();
+ Array.ForEach(CultureInfo.GetCultures(CultureTypes.NeutralCultures),
+ culture => names.Add(culture.Name));
+ names.Sort();
+ foreach (var name in names)
+ {
+ // Ignore the invariant culture.
+ if (name == "") continue;
+
+ ListSimilarChildCultures(name);
+ }
+ }
+
+ private static void ListSimilarChildCultures(String name)
+ {
+ // Create the neutral DateTimeFormatInfo object.
+ DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(name).DateTimeFormat;
+ // Retrieve all specific cultures of the neutral culture.
+ CultureInfo[] cultures = Array.FindAll(CultureInfo.GetCultures(CultureTypes.SpecificCultures),
+ culture => culture.Name.StartsWith(name + "-", StringComparison.OrdinalIgnoreCase));
+ // Create an array of DateTimeFormatInfo properties
+ PropertyInfo[] properties = typeof(DateTimeFormatInfo).GetProperties(BindingFlags.Instance | BindingFlags.Public);
+ bool hasOneMatch = false;
+
+ foreach (var ci in cultures)
+ {
+ bool match = true;
+ // Get the DateTimeFormatInfo for a specific culture.
+ DateTimeFormatInfo specificDtfi = ci.DateTimeFormat;
+ // Compare the property values of the two.
+ foreach (var prop in properties)
+ {
+ // We're not interested in the value of IsReadOnly.
+ if (prop.Name == "IsReadOnly") continue;
+
+ // For arrays, iterate the individual elements to see if they are the same.
+ if (prop.PropertyType.IsArray)
+ {
+ IList nList = (IList)prop.GetValue(dtfi, null);
+ IList sList = (IList)prop.GetValue(specificDtfi, null);
+ if (nList.Count != sList.Count)
+ {
+ match = false;
+ Console.WriteLine($" Different n in {prop.Name} array for {name} and {ci.Name}");
+ break;
+ }
+
+ for (int ctr = 0; ctr < nList.Count; ctr++)
+ {
+ if (!nList[ctr].Equals(sList[ctr]))
+ {
+ match = false;
+ Console.WriteLine($" {prop.Name} value different for {name} and {ci.Name}");
+ break;
+ }
+ }
+
+ if (!match) break;
+ }
+ // Get non-array values.
+ else
+ {
+ Object specificValue = prop.GetValue(specificDtfi);
+ Object neutralValue = prop.GetValue(dtfi);
+
+ // Handle comparison of Calendar objects.
+ if (prop.Name == "Calendar")
+ {
+ // The cultures have a different calendar type.
+ if (specificValue.ToString() != neutralValue.ToString())
+ {
+ Console.WriteLine($" Different calendar types for {name} and {ci.Name}");
+ match = false;
+ break;
+ }
+
+ if (specificValue is GregorianCalendar)
+ {
+ if (((GregorianCalendar)specificValue).CalendarType != ((GregorianCalendar)neutralValue).CalendarType)
+ {
+ Console.WriteLine($" Different Gregorian calendar types for {name} and {ci.Name}");
+ match = false;
+ break;
+ }
+ }
+ }
+ else if (!specificValue.Equals(neutralValue))
+ {
+ match = false;
+ Console.WriteLine($" Different {prop.Name} values for {name} and {ci.Name}");
+ break;
+ }
+ }
+ }
+ if (match)
+ {
+ Console.WriteLine($"DateTimeFormatInfo object for '{name}' matches '{ci.Name}'");
+ hasOneMatch = true;
+ }
+ }
+ if (!hasOneMatch)
+ Console.WriteLine($"DateTimeFormatInfo object for '{name}' --> No Match");
+
+ Console.WriteLine();
+ }
+}
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse1.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse1.cs
new file mode 100644
index 00000000000..d1a51b3cf63
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse1.cs
@@ -0,0 +1,45 @@
+//
+using System;
+using System.Globalization;
+
+public class ParseEx1
+{
+ public static void Main()
+ {
+ string[] dateStrings = { "08/18/2014", "01/02/2015" };
+ string[] cultureNames = { "en-US", "en-GB", "fr-FR", "fi-FI" };
+
+ foreach (var cultureName in cultureNames)
+ {
+ CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName);
+ Console.WriteLine($"Parsing strings using the {culture.Name} culture.");
+ foreach (var dateStr in dateStrings)
+ {
+ try
+ {
+ Console.WriteLine(String.Format(culture,
+ " '{0}' --> {1:D}", dateStr,
+ DateTime.Parse(dateStr, culture)));
+ }
+ catch (FormatException)
+ {
+ Console.WriteLine($" Unable to parse '{dateStr}'");
+ }
+ }
+ }
+ }
+}
+// The example displays the following output:
+// Parsing strings using the en-US culture.
+// '08/18/2014' --> Monday, August 18, 2014
+// '01/02/2015' --> Friday, January 02, 2015
+// Parsing strings using the en-GB culture.
+// Unable to parse '08/18/2014'
+// '01/02/2015' --> 01 February 2015
+// Parsing strings using the fr-FR culture.
+// Unable to parse '08/18/2014'
+// '01/02/2015' --> dimanche 1 février 2015
+// Parsing strings using the fi-FI culture.
+// Unable to parse '08/18/2014'
+// '01/02/2015' --> 1. helmikuuta 2015
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse2.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse2.cs
new file mode 100644
index 00000000000..3888b6215d9
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/parse2.cs
@@ -0,0 +1,36 @@
+//
+using System;
+using System.Globalization;
+
+public class ParseEx2
+{
+ public static void Main()
+ {
+ string inputDate = "14/05/10";
+
+ CultureInfo[] cultures = { CultureInfo.GetCultureInfo("en-US"),
+ CultureInfo.CreateSpecificCulture("en-US") };
+
+ foreach (var culture in cultures)
+ {
+ try
+ {
+ Console.WriteLine($"{culture.Name} culture reflects user overrides: {culture.UseUserOverride}");
+ DateTime occasion = DateTime.Parse(inputDate, culture);
+ Console.WriteLine($"'{inputDate}' --> {occasion.ToString("D", CultureInfo.InvariantCulture)}");
+ }
+ catch (FormatException)
+ {
+ Console.WriteLine($"Unable to parse '{inputDate}'");
+ }
+ Console.WriteLine();
+ }
+ }
+}
+// The example displays the following output:
+// en-US culture reflects user overrides: False
+// Unable to parse '14/05/10'
+//
+// en-US culture reflects user overrides: True
+// '14/05/10' --> Saturday, 10 May 2014
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/project.csproj b/snippets/csharp/System.Globalization/DateTimeFormatInfo/project.csproj
new file mode 100644
index 00000000000..cb4ea68ebe3
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/project.csproj
@@ -0,0 +1,9 @@
+
+
+
+ Library
+ net10.0
+ enable
+
+
+
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize1.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize1.cs
new file mode 100644
index 00000000000..c7b73185d3f
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize1.cs
@@ -0,0 +1,28 @@
+//
+using System;
+using System.Globalization;
+using System.IO;
+
+public class SerializeEx1
+{
+ public static void Main()
+ {
+ StreamWriter sw = new StreamWriter(@".\DateData.dat");
+ // Define a date and time to serialize.
+ DateTime originalDate = new DateTime(2014, 08, 18, 08, 16, 35);
+ // Display information on the date and time.
+ Console.WriteLine($"Date to serialize: {originalDate:F}");
+ Console.WriteLine($"Current Culture: {CultureInfo.CurrentCulture.Name}");
+ Console.WriteLine($"Time Zone: {TimeZoneInfo.Local.DisplayName}");
+ // Convert the date value to UTC.
+ DateTime utcDate = originalDate.ToUniversalTime();
+ // Serialize the UTC value.
+ sw.Write(utcDate.ToString("o", DateTimeFormatInfo.InvariantInfo));
+ sw.Close();
+ }
+}
+// The example displays the following output:
+// Date to serialize: Monday, August 18, 2014 8:16:35 AM
+// Current Culture: en-US
+// Time Zone: (UTC-08:00) Pacific Time (US & Canada)
+//
diff --git a/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize2.cs b/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize2.cs
new file mode 100644
index 00000000000..42e02b9c592
--- /dev/null
+++ b/snippets/csharp/System.Globalization/DateTimeFormatInfo/serialize2.cs
@@ -0,0 +1,29 @@
+//
+using System;
+using System.Globalization;
+using System.IO;
+
+public class SerializeEx2
+{
+ public static void Main()
+ {
+ // Open the file and retrieve the date string.
+ StreamReader sr = new StreamReader(@".\DateData.dat");
+ String dateValue = sr.ReadToEnd();
+
+ // Parse the date.
+ DateTime parsedDate = DateTime.ParseExact(dateValue, "o",
+ DateTimeFormatInfo.InvariantInfo);
+ // Convert it to local time.
+ DateTime restoredDate = parsedDate.ToLocalTime();
+ // Display information on the date and time.
+ Console.WriteLine($"Deserialized date: {restoredDate:F}");
+ Console.WriteLine($"Current Culture: {CultureInfo.CurrentCulture.Name}");
+ Console.WriteLine($"Time Zone: {TimeZoneInfo.Local.DisplayName}");
+ }
+}
+// The example displays the following output:
+// Deserialized date: lundi 18 août 2014 17:16:35
+// Current Culture: fr-FR
+// Time Zone: (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
+//
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Async1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Async1.vb
new file mode 100644
index 00000000000..1a14275abd1
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Async1.vb
@@ -0,0 +1,42 @@
+' Visual Basic .NET Document
+Option Infer On
+Option Strict On
+
+'
+Imports System.Globalization
+Imports System.Threading
+
+Module Example1
+ Public Sub S1()
+ Dim tasks As New List(Of Task)
+ Console.WriteLine("The current culture is {0}",
+ Thread.CurrentThread.CurrentCulture.Name)
+ Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-BR")
+ ' Change the current culture to Portuguese (Brazil).
+ Console.WriteLine("Current culture changed to {0}",
+ Thread.CurrentThread.CurrentCulture.Name)
+ Console.WriteLine("Application thread is thread {0}",
+ Thread.CurrentThread.ManagedThreadId)
+ ' Launch six tasks and display their current culture.
+ For ctr As Integer = 0 To 5
+ tasks.Add(Task.Run(Sub()
+ Console.WriteLine("Culture of task {0} on thread {1} is {2}",
+ Task.CurrentId,
+ Thread.CurrentThread.ManagedThreadId,
+ Thread.CurrentThread.CurrentCulture.Name)
+ End Sub))
+ Next
+ Task.WaitAll(tasks.ToArray())
+ End Sub
+End Module
+' The example displays output like the following:
+' The current culture is en-US
+' Current culture changed to pt-BR
+' Application thread is thread 9
+' Culture of task 2 on thread 11 is pt-BR
+' Culture of task 1 on thread 10 is pt-BR
+' Culture of task 3 on thread 11 is pt-BR
+' Culture of task 5 on thread 11 is pt-BR
+' Culture of task 6 on thread 11 is pt-BR
+' Culture of task 4 on thread 10 is pt-BR
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Get1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Get1.vb
new file mode 100644
index 00000000000..6bc28fe84f8
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Get1.vb
@@ -0,0 +1,16 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+
+Module Example3
+ Public Sub S1()
+ Dim culture As CultureInfo = CultureInfo.CurrentCulture
+ Console.WriteLine("The current culture is {0} [{1}]",
+ culture.NativeName, culture.Name)
+ End Sub
+End Module
+' The example displays output like the following:
+' The current culture is English (United States) [en-US]
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Program.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Program.vb
new file mode 100644
index 00000000000..95f459e37e4
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Program.vb
@@ -0,0 +1,5 @@
+Public Class Program
+ Public Shared Sub Main()
+ Example1.S1()
+ End Sub
+End Class
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Project.vbproj b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Project.vbproj
new file mode 100644
index 00000000000..f99395b4b2b
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Project.vbproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ net10.0
+
+
+
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/aspculture13.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/aspculture13.vb
new file mode 100644
index 00000000000..91257a0b53f
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/aspculture13.vb
@@ -0,0 +1,23 @@
+' Visual Basic .NET Document
+Option Strict On
+
+Imports System.Globalization
+Imports System.Threading
+
+Module Example
+ Public Sub S1()
+ '
+ Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))
+ '
+ End Sub
+End Module
+
+
+Public Class Request
+ Private Shared langs(3) As String
+ Public Shared ReadOnly Property UserLanguages As String()
+ Get
+ Return langs
+ End Get
+ End Property
+End Class
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/changeculture11.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/changeculture11.vb
new file mode 100644
index 00000000000..59a55590241
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/changeculture11.vb
@@ -0,0 +1,35 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+Imports System.Threading
+
+Public Class Info : Inherits MarshalByRefObject
+ Public Sub ShowCurrentCulture()
+ Console.WriteLine("Culture of {0} in application domain {1}: {2}",
+ Thread.CurrentThread.Name,
+ AppDomain.CurrentDomain.FriendlyName,
+ CultureInfo.CurrentCulture.Name)
+ End Sub
+End Class
+
+Module Example2
+ Public Sub S1()
+ Dim inf As New Info()
+ ' Set the current culture to Dutch (Netherlands).
+ Thread.CurrentThread.Name = "MainThread"
+ CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL")
+ inf.ShowCurrentCulture()
+
+ ' Create a new application domain.
+ Dim ad As AppDomain = AppDomain.CreateDomain("Domain2")
+ Dim inf2 As Info = CType(ad.CreateInstanceAndUnwrap(GetType(Info).Assembly.FullName, "Info"),
+ Info)
+ inf2.ShowCurrentCulture()
+ End Sub
+End Module
+' This example displays the following output:
+' Culture of MainThread in application domain Example.exe: nl-NL
+' Culture of MainThread in application domain Domain2: nl-NL
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/specific12.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/specific12.vb
new file mode 100644
index 00000000000..87380dd0c01
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/specific12.vb
@@ -0,0 +1,30 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+Imports System.Threading
+
+Module Example4
+ Public Sub S1()
+ Dim value As Double = 1634.92
+ CultureInfo.CurrentCulture = New CultureInfo("fr-CA")
+ Console.WriteLine("Current Culture: {0}",
+ CultureInfo.CurrentCulture.Name)
+ Console.WriteLine("{0:C2}", value)
+ Console.WriteLine()
+
+ Thread.CurrentThread.CurrentCulture = New CultureInfo("fr")
+ Console.WriteLine("Current Culture: {0}",
+ CultureInfo.CurrentCulture.Name)
+ Console.WriteLine("{0:C2}", value)
+ End Sub
+End Module
+' The example displays the following output:
+' Current Culture: fr-CA
+' 1 634,92 $
+'
+' Current Culture: fr
+' 1 634,92 €
+'
+
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Async1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Async1.vb
new file mode 100644
index 00000000000..1b6cc161e69
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Async1.vb
@@ -0,0 +1,42 @@
+' Visual Basic .NET Document
+Option Infer On
+Option Strict On
+
+'
+Imports System.Globalization
+Imports System.Threading
+
+Module Example1
+ Public Sub Main()
+ Dim tasks As New List(Of Task)
+ Console.WriteLine("The current UI culture is {0}",
+ Thread.CurrentThread.CurrentUICulture.Name)
+ Thread.CurrentThread.CurrentUICulture = New CultureInfo("pt-BR")
+ ' Change the current UI culture to Portuguese (Brazil).
+ Console.WriteLine("Current culture changed to {0}",
+ Thread.CurrentThread.CurrentUICulture.Name)
+ Console.WriteLine("Application thread is thread {0}",
+ Thread.CurrentThread.ManagedThreadId)
+ ' Launch six tasks and display their current culture.
+ For ctr As Integer = 0 To 5
+ tasks.Add(Task.Run(Sub()
+ Console.WriteLine("Culture of task {0} on thread {1} is {2}",
+ Task.CurrentId,
+ Thread.CurrentThread.ManagedThreadId,
+ Thread.CurrentThread.CurrentUICulture.Name)
+ End Sub))
+ Next
+ Task.WaitAll(tasks.ToArray())
+ End Sub
+End Module
+' The example displays output like the following:
+' The current culture is en-US
+' Current culture changed to pt-BR
+' Application thread is thread 9
+' Culture of task 2 on thread 11 is pt-BR
+' Culture of task 1 on thread 10 is pt-BR
+' Culture of task 3 on thread 11 is pt-BR
+' Culture of task 5 on thread 11 is pt-BR
+' Culture of task 6 on thread 11 is pt-BR
+' Culture of task 4 on thread 10 is pt-BR
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Get1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Get1.vb
new file mode 100644
index 00000000000..96b9294dac3
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Get1.vb
@@ -0,0 +1,16 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+
+Module Example3
+ Public Sub Main()
+ Dim culture As CultureInfo = CultureInfo.CurrentCulture
+ Console.WriteLine("The current UI culture is {0} [{1}]",
+ culture.NativeName, culture.Name)
+ End Sub
+End Module
+' The example displays output like the following:
+' The current UI culture is English (United States) [en-US]
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Project.vbproj b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Project.vbproj
new file mode 100644
index 00000000000..874c98f3477
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Project.vbproj
@@ -0,0 +1,8 @@
+
+
+
+ Library
+ net10.0
+
+
+
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.vb
new file mode 100644
index 00000000000..2dfafdb2692
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.vb
@@ -0,0 +1,20 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+
+Module Example2
+ Public Sub Main()
+ Console.WriteLine("The current UI culture: {0}",
+ CultureInfo.CurrentUICulture.Name)
+
+ CultureInfo.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr-FR")
+ Console.WriteLine("The current UI culture: {0}",
+ CultureInfo.CurrentUICulture.Name)
+ End Sub
+End Module
+' The example displays output like the following:
+' The current UI culture: en-US
+' The current UI culture: fr-FR
+'
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/Project.vbproj b/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/Project.vbproj
new file mode 100644
index 00000000000..874c98f3477
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/Project.vbproj
@@ -0,0 +1,8 @@
+
+
+
+ Library
+ net10.0
+
+
+
diff --git a/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/persist1.vb b/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/persist1.vb
new file mode 100644
index 00000000000..cb6e6ef721d
--- /dev/null
+++ b/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/persist1.vb
@@ -0,0 +1,53 @@
+' Visual Basic .NET Document
+Option Strict On
+
+'
+Imports System.Globalization
+Imports System.IO
+
+Module Example
+ Public Sub Main()
+ ' Persist the date and time data.
+ Dim sw As New StreamWriter(".\DateData.dat")
+
+ ' Create a DateTime value.
+ Dim dtIn As DateTime = DateTime.Now
+ ' Retrieve a CultureInfo object.
+ Dim invC As CultureInfo = CultureInfo.InvariantCulture
+
+ ' Convert the date to a string and write it to a file.
+ sw.WriteLine(dtIn.ToString("r", invC))
+ sw.Close()
+
+ ' Restore the date and time data.
+ Dim sr As New StreamReader(".\DateData.dat")
+ Dim input As String = String.Empty
+ Do While sr.Peek() >= 0
+ input = sr.ReadLine()
+ Console.WriteLine("Stored data: {0}" , input)
+ Console.WriteLine()
+
+ ' Parse the stored string.
+ Dim dtOut As DateTime = DateTime.Parse(input, invC, DateTimeStyles.RoundtripKind)
+
+ ' Create a French (France) CultureInfo object.
+ Dim frFr As New CultureInfo("fr-FR")
+ ' Displays the date formatted for the "fr-FR" culture.
+ Console.WriteLine("Date formatted for the {0} culture: {1}" ,
+ frFr.Name, dtOut.ToString("f", frFr))
+
+ ' Creates a German (Germany) CultureInfo object.
+ Dim deDe As New CultureInfo("de-De")
+ ' Displays the date formatted for the "de-DE" culture.
+ Console.WriteLine("Date formatted for {0} culture: {1}" ,
+ deDe.Name, dtOut.ToString("f", deDe))
+ Loop
+ sr.Close()
+ End Sub
+End Module
+' The example displays the following output:
+' Stored data: Tue, 15 May 2012 16:34:16 GMT
+'
+' Date formatted for the fr-FR culture: mardi 15 mai 2012 16:34
+' Date formatted for de-DE culture: Dienstag, 15. Mai 2012 16:34
+'
diff --git a/xml/System.Globalization/CompareInfo.xml b/xml/System.Globalization/CompareInfo.xml
index 2a45163860c..292b5d9f21f 100644
--- a/xml/System.Globalization/CompareInfo.xml
+++ b/xml/System.Globalization/CompareInfo.xml
@@ -84,9 +84,31 @@
## Remarks
- For more information about this API, see [Supplemental API remarks for CompareInfo](/dotnet/fundamentals/runtime-libraries/system-globalization-compareinfo).
+ Conventions for comparing and sorting data vary from culture to culture. For example, sort order may be based on phonetics or on the visual representation of characters. In East Asian languages, characters are sorted by the stroke and radical of ideographs. Sorting also depends on the order languages and cultures use for the alphabet. For example, the Danish language has an "Æ" character that it sorts after "Z" in the alphabet. In addition, comparisons may be case-sensitive or case-insensitive, and casing rules may also differ by culture. The class is responsible for maintaining this culture-sensitive string comparison data and for performing culture-sensitive string operations.
- ## Example
+Typically, you do not have to instantiate a object directly, because one is used implicitly by all non-ordinal string comparison operations, including calls to the method. However, if you do want to retrieve a object, you can do it in one of these ways:
+
+- By retrieving the value of the property for a particular culture.
+
+- By calling the static method with a culture name. This allows for late-bound access to a object.
+
+## Ignored search values
+
+Character sets include ignorable characters, which are characters that are not considered when performing a linguistic or culture-sensitive comparison. Comparison methods such as and do not consider such characters when they perform a culture-sensitive comparison. Ignorable characters include:
+
+- . Culture-sensitive comparison methods will always find an empty string at the beginning (index zero) of the string being searched.
+
+- A character or string consisting of characters with code points that are not considered in the operation because of comparison options, In particular, the and options produce searches in which symbols and nonspacing combining characters are ignored.
+
+- A string with code points that have no linguistic significance. For example, a soft hyphen (U+00AD) is always ignored in a culture-sensitive string comparison.
+
+## Security considerations
+
+If a security decision depends on a string comparison or a case change, you should use the property to ensure that the behavior is consistent, regardless of the culture settings of the operating system.
+
+> [!NOTE]
+> When possible, you should use string comparison methods that have a parameter of type to specify the kind of comparison expected. As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify or for security comparisons.
+## Example
The following example shows how the object associated with a object affects string comparison.
diff --git a/xml/System.Globalization/CompareOptions.xml b/xml/System.Globalization/CompareOptions.xml
index 83695e78a2a..5adfea83721 100644
--- a/xml/System.Globalization/CompareOptions.xml
+++ b/xml/System.Globalization/CompareOptions.xml
@@ -77,8 +77,18 @@ In .NET 5 and later, the cross-platform ICU (International Components for Unicod
For more information about the change, including how to restore the previous Unicode handler, see [.NET globalization and ICU](/dotnet/core/extensions/globalization-icu).
-For more information about this API, see [Supplemental API remarks for CompareOptions](/dotnet/fundamentals/runtime-libraries/system-globalization-compareoptions).
+The options denote case sensitivity or necessity to ignore types of characters.
+.NET uses three distinct ways of sorting: word sort, string sort, and ordinal sort. Word sort performs a culture-sensitive comparison of strings. Certain nonalphanumeric characters might have special weights assigned to them. For example, the hyphen ("-") might have a very small weight assigned to it so that "coop" and "co-op" appear next to each other in a sorted list. String sort is similar to word sort, except that there are no special cases. Therefore, all nonalphanumeric symbols come before all alphanumeric characters. Ordinal sort compares strings based on the Unicode values of each element of the string. For a downloadable set of text files that contain information on the character weights used in sorting and comparison operations for Windows operating systems, see [Sorting Weight Tables](https://www.microsoft.com/download/details.aspx?id=10921). For the sort weight table for Linux and macOS, see the [Default Unicode Collation Element Table](https://www.unicode.org/Public/UCA/latest/allkeys.txt). The specific version of the sort weight table on Linux and macOS depends on the version of the [International Components for Unicode](https://icu.unicode.org/) libraries installed on the system. For information on ICU versions and the Unicode versions that they implement, see [Downloading ICU](https://icu.unicode.org/download).
+
+The `StringSort` value can only be used with and . is thrown if the StringSort value is used with , , , or .
+
+> [!NOTE]
+> When possible, you should use string comparison methods that accept a value to specify the kind of comparison expected. As a general rule, user-facing comparisons are best served by the use of linguistic options (using the current culture), while security comparisons should specify `Ordinal` or `OrdinalIgnoreCase`.
+
+## Culture-sensitive sorts
+
+[!INCLUDE[platform-note](includes/c-and-posix-cultures.md)]
## Examples
The following code example shows how each of the `CompareOptions` values affect string comparisons.
diff --git a/xml/System.Globalization/CultureInfo.xml b/xml/System.Globalization/CultureInfo.xml
index 4c11f4c43c7..313aa18fefd 100644
--- a/xml/System.Globalization/CultureInfo.xml
+++ b/xml/System.Globalization/CultureInfo.xml
@@ -83,9 +83,224 @@
## Remarks
- For more information about this API, see [Supplemental API remarks for CultureInfo](/dotnet/fundamentals/runtime-libraries/system-globalization-cultureinfo).
+ The class provides culture-specific information, such as the language, sublanguage, country/region, calendar, and conventions associated with a particular culture. This class also provides access to culture-specific instances of the , , , and objects. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings. The class is used either directly or indirectly by classes that format, parse, or manipulate culture-specific data, such as , , , and the numeric types.
- ## Example
+## Culture names and identifiers
+
+The class specifies a unique name for each culture, based on RFC 4646. The name is a combination of an ISO 639 two-letter or three-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code associated with a country or region. In addition, for apps that are running under Windows 10 or later, culture names that correspond to valid BCP-47 language tags are supported.
+
+> [!NOTE]
+> When a culture name is passed to a class constructor or a method such as or , its case is not significant.
+
+The format for the culture name based on RFC 4646 is *`languagecode2`*-*`country/regioncode2`*, where *`languagecode2`* is the two-letter language code and *`country/regioncode2`* is the two-letter subculture code. Examples include `ja-JP` for Japanese (Japan) and `en-US` for English (United States). In cases where a two-letter language code is not available, a three-letter code as defined in ISO 639-3 is used.
+
+Some culture names also specify an ISO 15924 script. For example, Cyrl specifies the Cyrillic script and Latn specifies the Latin script. A culture name that includes a script uses the pattern *`languagecode2`*-*`scripttag`*-*`country/regioncode2`*. An example of this type of culture name is `uz-Cyrl-UZ` for Uzbek (Cyrillic, Uzbekistan). On Windows operating systems before Windows Vista, a culture name that includes a script uses the pattern *`languagecode2`*-*`country/regioncode2`*-*`scripttag`*, for example, `uz-UZ-Cyrl` for Uzbek (Cyrillic, Uzbekistan).
+
+A neutral culture is specified by only the two-letter, lowercase language code. For example, `fr` specifies the neutral culture for French, and `de` specifies the neutral culture for German.
+
+> [!NOTE]
+> There are two culture names that contradict this rule. The cultures Chinese (Simplified), named `zh-Hans`, and Chinese (Traditional), named `zh-Hant`, are neutral cultures. The culture names represent the current standard and should be used unless you have a reason for using the older names `zh-CHS` and `zh-CHT`.
+
+A culture identifier is a standard international numeric abbreviation and has the components necessary to uniquely identify one of the installed cultures. Your application can use predefined culture identifiers or define custom identifiers.
+
+Certain predefined culture names and identifiers are used by this and other classes in the namespace. For detailed culture information for Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47).
+
+The culture names and identifiers represent only a subset of cultures that can be found on a particular computer. Windows versions or service packs can change the available cultures. Applications can add custom cultures using the class. Users can add their own custom cultures using the [Microsoft Locale Builder](https://www.microsoft.com/download/details.aspx?id=41158) tool. Microsoft Locale Builder is written in managed code using the `CultureAndRegionInfoBuilder` class.
+
+Several distinct names are closely associated with a culture, notably the names associated with the following class members:
+
+-
+-
+-
+
+## Invariant, neutral, and specific cultures
+
+The cultures are generally grouped into three sets: invariant cultures, neutral cultures, and specific cultures.
+
+An invariant culture is culture-insensitive. Your application specifies the invariant culture by name using an empty string ("") or by its identifier. defines an instance of the invariant culture. It is associated with the English language but not with any country/region. It is used in almost any method in the `Globalization` namespace that requires a culture.
+
+A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, `fr` is the neutral name for the French culture, and `fr-FR` is the name of the specific French (France) culture. Note that Chinese (Simplified) and Chinese (Traditional) are also considered neutral cultures.
+
+Creating an instance of a class for a neutral culture is not recommended because the data it contains is arbitrary. To display and sort data, specify both the language and region. Additionally, the property of a object created for a neutral culture returns only the country and does not include the region.
+
+The defined cultures have a hierarchy in which the parent of a specific culture is a neutral culture and the parent of a neutral culture is the invariant culture. The property contains the neutral culture associated with a specific culture. Custom cultures should define the property in conformance with this pattern.
+
+If the resources for a specific culture are not available in the operating system, the resources for the associated neutral culture are used. If the resources for the neutral culture are not available, the resources embedded in the main assembly are used. For more information on the resource fallback process, see [Packaging and Deploying Resources](/dotnet/framework/resources/packaging-and-deploying-resources-in-desktop-apps).
+
+The list of locales in the Windows API is slightly different from the list of cultures supported by .NET. If interoperability with Windows is required, for example, through the p/invoke mechanism, the application should use a specific culture that's defined for the operating system. Use of the specific culture ensures consistency with the equivalent Windows locale, which is identified with a locale identifier that is the same as .
+
+A or a can be created only for the invariant culture or for specific cultures, not for neutral cultures.
+
+If is the but the is not set to `zh-TW`, then , , and return an empty string ("").
+
+## Custom cultures
+
+On Windows, you can create custom locales. For more information, see [Custom locales](/windows/win32/intl/custom-locales).
+
+## CultureInfo and cultural data
+
+.NET derives its cultural data from a one of a variety of sources, depending on implementation, platform, and version:
+
+- In all versions of .NET (Core) running on Unix platforms or Windows 10 and later versions, cultural data is provided by the [International Components for Unicode (ICU) Library](https://icu.unicode.org/). The specific version of the ICU Library depends on the individual operating system.
+- In all versions of .NET (Core) running on Windows 9 and earlier versions, cultural data is provided by the Windows operating system.
+- In .NET Framework 4 and later versions, cultural data is provided by the Windows operating system.
+
+Because of this, a culture available on a particular .NET implementation, platform, or version may not be available on a different .NET implementation, platform, or version.
+
+Some `CultureInfo` objects differ depending on the underlying platform. In particular, `zh-CN`, or Chinese (Simplified, China) and `zh-TW`, or Chinese (Traditional, Taiwan), are available cultures on Windows systems, but they are aliased cultures on Unix systems. "zh-CN" is an alias for the "zh-Hans-CN" culture, and "zh-TW" is an alias for the "zh-Hant-TW" culture. Aliased cultures are not returned by calls to the method and may have different property values, including different cultures, than their Windows counterparts. For the `zh-CN` and `zh-TW` cultures, these differences include the following:
+
+- On Windows systems, the parent culture of the "zh-CN" culture is "zh-Hans", and the parent culture of the "zh-TW" culture is "zh-Hant". The parent culture of both these cultures is "zh". On Unix systems, the parents of both cultures are "zh". This means that, if you don't provide culture-specific resources for the "zh-CN" or "zh-TW" cultures but do provide a resources for the neutral "zh-Hans" or "zh-Hant" culture, your application will load the resources for the neutral culture on Windows but not on Unix. On Unix systems, you must explicitly set the thread's to either "zh-Hans" or "zh-Hant".
+
+- On Windows systems, calling on an instance that represents the "zh-CN" culture and passing it a "zh-Hans-CN" instance returns `true`. On Unix systems, the method call returns `false`. This behavior also applies to calling on a "zh-TW" instance and passing it a "zh-Hant-Tw" instance.
+
+## Dynamic culture data
+
+Except for the invariant culture, culture data is dynamic. This is true even for the predefined cultures. For example, countries or regions adopt new currencies, change their spellings of words, or change their preferred calendar, and culture definitions change to track this. Custom cultures are subject to change without notice, and any specific culture might be overridden by a custom replacement culture. Also, as discussed below, an individual user can override cultural preferences. Applications should always obtain culture data at runtime.
+
+> [!CAUTION]
+> When saving data, your application should use the invariant culture, a binary format, or a specific culture-independent format. Data saved according to the current values associated with a particular culture, other than the invariant culture, might become unreadable or might change in meaning if that culture changes.
+
+## The current culture and current UI culture
+
+Every thread in a .NET application has a current culture and a current UI culture. The current culture determines the formatting conventions for dates, times, numbers, and currency values, the sort order of text, casing conventions, and the ways in which strings are compared. The current UI culture is used to retrieve culture-specific resources at runtime.
+
+> [!NOTE]
+> For information on how the current and current UI culture is determined on a per-thread basis, see the [Culture and threads](#culture-and-threads) section. For information on how the current and current UI culture is determined on threads executing in a new application domain, and on threads that cross application domain boundaries, see the [Culture and application domains](#culture-and-application-domains) section. For information on how the current and current UI culture is determined on threads performing task-based asynchronous operations, see the [Culture and task-based asynchronous operations](#culture-and-task-based-asynchronous-operations) section.
+
+For more detailed information on the current culture, see the property. For more detailed information on the current UI culture, see the property topic.
+
+### Retrieve the current and current UI cultures
+
+You can get a object that represents the current culture in either of two ways:
+
+- By retrieving the value of the property.
+- By retrieving the value of the [Thread.CurrentThread.CurrentCulture]() property.
+
+The following example retrieves both property values, compares them to show that they are equal, and displays the name of the current culture.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Current1.cs" id="Snippet1":::
+
+You can get a object that represents the current UI culture in either of two ways:
+
+- By retrieving the value of the property.
+
+- By retrieving the value of the [Thread.CurrentThread.CurrentUICulture]() property.
+
+The following example retrieves both property values, compares them to show that they are equal, and displays the name of the current UI culture.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentUI1.cs" id="Snippet2":::
+
+### Set the current and current UI cultures
+
+To change the culture and UI culture of a thread, do the following:
+
+1. Instantiate a object that represents that culture by calling a class constructor and passing it the name of the culture. The constructor instantiates a object that reflects user overrides if the new culture is the same as the current Windows culture. The constructor allows you to specify whether the newly instantiated object reflects user overrides if the new culture is the same as the current Windows culture.
+
+2. Assign the object to the or property on .NET Core and .NET Framework 4.6 and later versions.
+
+The following example retrieves the current culture. If it is anything other than the French (France) culture, it changes the current culture to French (France). Otherwise, it changes the current culture to French (Luxembourg).
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Change1.cs" id="Snippet3":::
+
+The following example retrieves the current culture. If it is anything other the Slovenian (Slovenia) culture, it changes the current culture to Slovenian (Slovenia). Otherwise, it changes the current culture to Croatian (Croatia).
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/ChangeUI1.cs" id="Snippet4":::
+
+## Get all cultures
+
+You can retrieve an array of specific categories of cultures or of all the cultures available on the local computer by calling the method. For example, you can retrieve custom cultures, specific cultures, or neutral cultures either alone or in combination.
+
+The following example calls the method twice, first with the enumeration member to retrieve all custom cultures, and then with the enumeration member to retrieve all replacement cultures.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/GetCultures1.cs" id="Snippet5":::
+
+## Culture and threads
+
+When a new application thread is started, its current culture and current UI culture are defined by the current system culture, and not by the current thread culture. The following example illustrates the difference. It sets the current culture and current UI culture of an application thread to the French (France) culture (fr-FR). If the current culture is already fr-FR, the example sets it to the English (United States) culture (en-US). It displays three random numbers as currency values and then creates a new thread, which, in turn, displays three more random numbers as currency values. But as the output from the example shows, the currency values displayed by the new thread do not reflect the formatting conventions of the French (France) culture, unlike the output from the main application thread.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/defaultthread1.cs" id="Snippet1":::
+
+You can set the culture and UI culture of all threads in an application domain by assigning a object that represents that culture to the and properties. The following example uses these properties to ensure that all threads in the default application domain share the same culture.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/setthreads1.cs" id="Snippet3":::
+
+> [!WARNING]
+> Although the and properties are static members, they define the default culture and default UI culture only for the application domain that is current at the time these property values are set. For more information, see the next section, [Culture and application domains](#culture-and-application-domains).
+
+When you assign values to the and properties, the culture and UI culture of the threads in the application domain also change if they have not explicitly been assigned a culture. However, these threads reflect the new culture settings only while they execute in the current application domain. If these threads execute in another application domain, their culture becomes the default culture defined for that application domain. As a result, we recommend that you always set the culture of the main application thread, and not rely on the and properties to change it.
+
+## Culture and application domains
+
+ and are static properties that explicitly define a default culture only for the application domain that is current when the property value is set or retrieved. The following example sets the default culture and default UI culture in the default application domain to French (France), and then uses the class and the delegate to set the default culture and UI culture in a new application domain to Russian (Russia). A single thread then executes two methods in each application domain. Note that the thread's culture and UI culture are not explicitly set; they are derived from the default culture and UI culture of the application domain in which the thread is executing. Note also that the and properties return the default values of the application domain that is current when the method call is made.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/appdomainex1.cs" id="Snippet1":::
+
+For more information about cultures and application domains, see the "Application Domains and Threads" section in the [Application Domains](/dotnet/framework/app-domains/application-domains) topic.
+
+## Culture and task-based asynchronous operations
+
+The [task-based asynchronous programming pattern](/dotnet/standard/parallel-programming/task-based-asynchronous-programming) uses and objects to asynchronously execute delegates on thread pool threads. The specific thread on which a particular task runs is not known in advance, but is determined only at runtime.
+
+For apps that target .NET Framework 4.6 or a later version, culture is part of an asynchronous operation's context. In other words, asynchronous operations by default inherit the values of the and properties of the thread from which they are launched. If the current culture or current UI culture differs from the system culture, the current culture crosses thread boundaries and becomes the current culture of the thread pool thread that is executing an asynchronous operation.
+
+The following example provides a simple illustration. The example defines a delegate, `formatDelegate`, that returns some numbers formatted as currency values. The example changes the current system culture to either French (France) or, if French (France) is already the current culture, English (United States). It then:
+
+- Invokes the delegate directly so that it runs synchronously on the main app thread.
+- Creates a task that executes the delegate asynchronously on a thread pool thread.
+- Creates a task that executes the delegate synchronously on the main app thread by calling the method.
+
+As the output from the example shows, when the current culture is changed to French (France), the current culture of the thread from which tasks are invoked asynchronously becomes the current culture for that asynchronous operation.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/asyncculture1.cs" id="Snippet1":::
+
+ and are per-app domain properties; that is, they establish a default culture for all threads not explicitly assigned a culture in a specific application domain. However, for apps that target .NET Framework 4.6 or later, the culture of the calling thread remains part of an asynchronous task's context even if the task crosses app domain boundaries.
+
+## CultureInfo object serialization
+
+When a object is serialized, all that is actually stored is and . It is successfully deserialized only in an environment where that has the same meaning. The following three examples show why this is not always the case:
+
+- If the property value is , and if that culture was first introduced in a particular version of the Windows operating system, it is not possible to deserialize it on an earlier version of Windows. For example, if a culture was introduced in Windows 10, it cannot be deserialized on Windows 8.
+
+- If the value is , and the computer on which it is deserialized does not have this user custom culture installed, it is not possible to deserialize it.
+
+- If the value is , and the computer on which it is deserialized does not have this replacement culture, it deserializes to the same name, but not all of the same characteristics. For example, if `en-US` is a replacement culture on computer A, but not on computer B, and if a object referring to this culture is serialized on computer A and deserialized on computer B, then none of the custom characteristics of the culture are transmitted. The culture deserializes successfully, but with a different meaning.
+
+## Control Panel overrides
+
+The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. In general, your applications should honor these user overrides.
+
+If is `true` and the specified culture matches the current culture of Windows, the uses those overrides, including user settings for the properties of the instance returned by the property, and the properties of the instance returned by the property. If the user settings are incompatible with the culture associated with the , for example, if the selected calendar is not one of the , the results of the methods and the values of the properties are undefined.
+
+## Alternate sort orders
+
+Some cultures support more than one sort order. For example:
+
+- The Spanish (Spain) culture has two sort orders: the default international sort order, and the traditional sort order. When you instantiate a object with the `es-ES` culture name, the international sort order is used. When you instantiate a object with the `es-ES-tradnl` culture name, the traditional sort order is used.
+
+- The `zh-CN` (Chinese (Simplified, PRC)) culture supports two sort orders: by pronunciation (the default) and by stroke count. When you instantiate a object with the `zh-CN` culture name, the default sort order is used. When you instantiate a object with a local identifier of 0x00020804, strings are sorted by stroke count.
+
+The following table lists the cultures that support alternate sort orders and the identifiers for the default and alternate sort orders.
+
+|Culture name|Culture|Default sort name and identifier|Alternate sort name and identifier|
+|------------------|-------------|--------------------------------------|----------------------------------------|
+|es-ES|Spanish (Spain)|International: 0x00000C0A|Traditional: 0x0000040A|
+|zh-TW|Chinese (Taiwan)|Stroke Count: 0x00000404|Bopomofo: 0x00030404|
+|zh-CN|Chinese (PRC)|Pronunciation: 0x00000804|Stroke Count: 0x00020804|
+|zh-HK|Chinese (Hong Kong SAR)|Stroke Count: 0x00000c04|Stroke Count: 0x00020c04|
+|zh-SG|Chinese (Singapore)|Pronunciation: 0x00001004|Stroke Count: 0x00021004|
+|zh-MO|Chinese (Macao SAR)|Pronunciation: 0x00001404|Stroke Count: 0x00021404|
+|ja-JP|Japanese (Japan)|Default: 0x00000411|Unicode: 0x00010411|
+|ko-KR|Korean (Korea)|Default: 0x00000412|Korean Xwansung - Unicode: 0x00010412|
+|de-DE|German (Germany)|Dictionary: 0x00000407|Phone Book Sort DIN: 0x00010407|
+|hu-HU|Hungarian (Hungary)|Default: 0x0000040e|Technical Sort: 0x0001040e|
+|ka-GE|Georgian (Georgia)|Traditional: 0x00000437|Modern Sort: 0x00010437|
+
+## The current culture and UWP apps
+
+In Universal Windows Platform (UWP) apps, the and properties are read-write, just as they are in .NET Framework and .NET Core apps. However, UWP apps recognize a single culture. The and properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
+
+In .NET apps, the current culture is a per-thread setting, and the and properties reflect the culture and UI culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection, which is a global setting. Setting the or property changes the culture of the entire app; culture cannot be set on a per-thread basis.
+## Example
The following example shows how to create a object for Spanish (Spain) with the international sort and another object with the traditional sort.
@@ -915,7 +1130,87 @@ If `name` is , the constr
Gets or sets the object that represents the culture used by the current thread and task-based asynchronous operations.
The culture used by the current thread and task-based asynchronous operations.
- For more information about this API, see Supplemental API remarks for CultureInfo.CurrentCulture.
+
+ object that's returned by the property and its associated objects determines the default format for dates, times, numbers, and currency values, the sorting order of text, casing conventions, and string comparisons.
+
+The current culture is a property of the executing thread. When you set this property to a object that represents a new culture, the value of the `Thread.CurrentThread.CurrentCulture` property also changes. However, we recommend that you always use the property to retrieve and set the current culture.
+
+The `CultureInfo` object that this property returns is read-only. That means you can't mutate the existing object, for example, by changing the `DateTimeFormat`. To change the date-time format or some other aspect of the current culture, create a new `CultureInfo` object and assign it to the property.
+
+## How a thread's culture is determined
+
+When a thread is started, its culture is initially determined as follows:
+
+- By retrieving the culture that is specified by the property in the application domain in which the thread is executing, if the property value is not `null`.
+
+- If the thread is a thread pool thread that is executing a task-based asynchronous operation, its culture is determined by the culture of the calling thread. The following example changes the current culture to Portuguese (Brazil) and launches six tasks, each of which displays its thread ID, its task ID, and its current culture. Each of the tasks (and the threads) has inherited the culture of the calling thread.
+
+ :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Async1.cs" id="Snippet14":::
+ :::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Async1.vb" id="Snippet14":::
+
+ For more information, see [Culture and task-based asynchronous operations](system-globalization-cultureinfo.md#culture-and-task-based-asynchronous-operations).
+
+- By calling the `GetUserDefaultLocaleName` function on Windows or the `uloc_getDefault` function from [ICU](https://icu-project.org/), which currently calls the POSIX `setlocale` function with category `LC_MESSAGES`, on Unix-like systems.
+
+Note that if you set a specific culture that is different from the system-installed culture or the user's preferred culture, and your application starts multiple threads, the current culture of those threads will be the culture that is returned by the `GetUserDefaultLocaleName` function, unless you assign a culture to the property in the application domain in which the thread is executing.
+
+For more information about how the culture of a thread is determined, see the "Culture and threads" section in the reference page.
+
+## Get the current culture
+
+The property is a per-thread setting; that is, each thread can have its own culture. You get the culture of the current thread by retrieving the value of the property, as the following example illustrates.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/Get1.cs" id="Snippet5":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/Get1.vb" id="Snippet5":::
+
+## Set the CurrentCulture property explicitly
+
+To change the culture that's used by an existing thread, you set the property to the new culture. If you explicitly change a thread's culture in this way, that change persists if the thread crosses application domain boundaries. The following example changes the current thread culture to Dutch (Netherlands). It also shows that, when the current thread crosses application domain boundaries, its current culture remains changed.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/changeculture11.cs" id="Snippet11":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/changeculture11.vb" id="Snippet11":::
+
+> [!NOTE]
+> Changing the culture by using the property requires a permission with the value set. Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. You cannot change thread culture in semi-trusted code.
+
+Starting with .NET Framework 4, you can explicitly change the current thread culture to either a specific culture (such as French (Canada)) or a neutral culture (such as French). When a object represents a neutral culture, the values of properties such as , , , , and reflect the specific culture that is associated with the neutral culture. For example, the dominant culture for the English neutral culture is English (United States); the dominant culture for the German culture is German (Germany). The following example illustrates the difference in formatting when the current culture is set to a specific culture, French (Canada), and a neutral culture, French.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/specific12.cs" id="Snippet12":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/specific12.vb" id="Snippet12":::
+
+You can also use the property along with the property to set the property of an ASP.NET application to the user's preferred culture, as the following example illustrates.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/aspculture13.cs" id="Snippet13":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentCulture/aspculture13.vb" id="Snippet13":::
+
+## The current culture and user overrides
+
+Windows allows users to override the standard property values of the object and its associated objects by using **Regional and Language Options** in Control Panel. The object returned by the property reflects these user overrides in the following cases:
+
+- If the current thread culture is set implicitly by the Windows `GetUserDefaultLocaleName` function.
+
+- If the current thread culture defined by the property corresponds to the current Windows system culture.
+
+- If the current thread culture is set explicitly to a culture returned by the method, and that culture corresponds to the current Windows system culture.
+
+- If the current thread culture is set explicitly to a culture instantiated by the constructor, and that culture corresponds to the current Windows system culture.
+
+In some cases, particularly for server applications, setting the current culture to a object that reflects user overrides may be undesirable. Instead, you can set the current culture to a object that does not reflect user overrides in the following ways:
+
+- By calling the constructor with a value of `false` for the `useUserOverride` argument.
+
+- By calling the method, which returns a cached, read-only object.
+
+## The current culture and UWP apps
+
+In Universal Windows Platform (UWP) apps, the property is read-write, just as it is in .NET Framework and .NET Core apps; you can use it both to get and to set the current culture. However, UWP apps do not distinguish between the current culture and the current UI culture. The and properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
+
+In .NET Framework and .NET Core apps, the current culture is a per-thread setting, and the property reflects the culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) property, which is a global setting. Setting the property changes the culture of the entire app; culture cannot be set on a per-thread basis.
+
+ ]]>
+
and of the current thread.
@@ -979,7 +1274,71 @@ The following example demonstrates how to change the
Gets or sets the object that represents the current user interface culture used by the Resource Manager to look up culture-specific resources at run time.
The culture used by the Resource Manager to look up culture-specific resources at run time.
- For more information about this API, see Supplemental API remarks for CultureInfo.CurrentUICulture.
+
+ property is a per-thread property. That is, each thread has its own current UI culture. This property is equivalent to retrieving or setting the object assigned to the `System.Threading.Thread.CurrentThread.CurrentUICulture` property. When a thread is started, its UI culture is initially determined as follows:
+
+- By retrieving the culture that is specified by the property in the application domain in which the thread is executing, if the property value is not `null`.
+
+- If the thread is a thread pool thread that is executing a task-based asynchronous operation and the app targets the .NET Framework 4.6 or a later version of the .NET Framework, its UI culture is determined by the UI culture of the calling thread. The following example changes the current UI culture to Portuguese (Brazil) and launches six tasks, each of which displays its thread ID, its task ID, and its current UI culture. Each of the tasks (and the threads) has inherited the UI culture of the calling thread.
+
+ :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Async1.cs" id="Snippet14":::
+ :::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Async1.vb" id="Snippet14":::
+
+ For more information, see the "Culture and task-based asynchronous operations" section in the documentation.
+
+- By calling the Windows `GetUserDefaultUILanguage` function.
+
+To change the user interface culture used by a thread, set the property to the new culture. If you explicitly change a thread's UI culture in this way, that change persists if the thread crosses application domain boundaries.
+
+> [!NOTE]
+> If you set the property value to a object that represents a new culture, the value of the `Thread.CurrentThread.CurrentCulture` property also changes.
+
+## Get the current UI culture
+
+The property is a per-thread setting; that is, each thread can have its own UI culture. You get the UI culture of the current thread by retrieving the value of the property, as the following example illustrates.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/Get1.cs" id="Snippet5":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/Get1.vb" id="Snippet5":::
+
+You can also retrieve the value of the current thread's UI culture from the property.
+
+## Explicitly set the current UI culture
+
+Starting with .NET Framework 4.6, you can change the current UI culture by assigning a object that represents the new culture to the property. The current UI culture can be set to either a specific culture (such as en-US or de-DE) or to a neutral culture (such as en or de). The following example sets the current UI culture to fr-FR or French (France).
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.cs" id="Snippet1":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/CurrentUICulture/currentuiculture1.vb" id="Snippet1":::
+
+In a multithreaded application, you can explicitly set the UI culture of any thread by assigning a object that represents that culture to the thread's property. If the thread whose culture you want to set is the current thread, you can assign the new culture to the property. When the UI culture of a thread is set explicitly, that thread retains the same culture even if it crosses application domain boundaries and executes code in another application domain.
+
+## Implicitly set the current UI culture
+
+When a thread, including the main application thread, is first created, by default its current UI culture is set as follows:
+
+- By using the culture defined by the property for the current application domain if the property value is not `null`.
+- By using the system's default culture. On systems that use the Windows operating system, the common language runtime calls the Windows `GetUserDefaultUILanguage` function to set the current UI culture. `GetUserDefaultUILanguage` returns the default UI culture set by the user. If the user has not set a default UI language, it returns the culture originally installed on the system.
+
+If the thread crosses application boundaries and executes code in another application domain, its culture is determined in the same way as that of a newly created thread.
+
+Note that if you set a specific UI culture that is different from the system-installed UI culture or the user's preferred UI culture, and your application starts multiple threads, the current UI culture of those threads will be the culture returned by the `GetUserDefaultUILanguage` function, unless you assign a culture to the property in the application domain in which the thread is executing.
+
+## Security considerations
+
+Changing the culture of the current thread requires a permission with the value set.
+
+> [!CAUTION]
+> Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. You cannot change thread culture in semi-trusted code.
+
+## The current UI culture and UWP apps
+
+In Universal Windows Platform (UWP) apps, the property is read-write, just as it is in .NET Framework and .NET Core apps; you can use it both to get and to set the current culture. However, UWP apps do not distinguish between the current culture and the current UI culture. The and properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
+
+In .NET Framework and .NET Core apps, the current UI culture is a per-thread setting, and the property reflects the UI culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) property, which is a global setting. Setting the property changes the culture of the entire app; culture cannot be set on a per-thread basis.
+
+ ]]>
+
and of the current thread.
@@ -2373,7 +2732,34 @@ Setting `predefinedOnly` to `true` will ensure a culture is created only if the
Gets the object that is culture-independent (invariant).
The object that is culture-independent (invariant).
- For more information about this API, see Supplemental API remarks for CultureInfo.InvariantCulture.
+
+ instantiation method. This property, , also retrieves an instance of the invariant culture. It can be used in almost any method in the namespace that requires a culture. The objects returned by properties such as , , and also reflect the string comparison and formatting conventions of the invariant culture.
+
+Unlike culture-sensitive data, which is subject to change by user customization or by updates to the .NET Framework or the operating system, invariant culture data is stable over time and across installed cultures and cannot be customized by users. This makes the invariant culture particularly useful for operations that require culture-independent results, such as formatting and parsing operations that persist formatted data, or sorting and ordering operations that require that data be displayed in a fixed order regardless of culture.
+
+## String operations
+
+You can use the invariant culture for culture-sensitive string operations that are not affected by the conventions of the current culture and that are consistent across cultures. For example, you may want sorted data to appear in a fixed order or apply a standard set of casing conventions to strings regardless of the current culture. To do this, you pass the object to a method that has a parameter, such as and .
+
+## Persisting data
+
+The property can be used to persist data in a culture-independent format. This provides a known format that does not change and that can be used to serialize and deserialize data across cultures. After the data is deserialized, it can be formatted appropriately based on the cultural conventions of the current user.
+
+For example, if you choose to persist date and time data in string form, you can pass the object to the or method to create the string, and you can pass the object to the or method to convert the string back to a date and time value. This technique ensures that the underlying date and time values do not change when the data is read or written by users from different cultures.
+
+The following example uses the invariant culture to persist a value as a string. It then parses the string and displays its value by using the formatting conventions of the French (France) and German (Germany) cultures.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/InvariantCulture/persist1.cs" id="Snippet1":::
+:::code language="vb" source="~/snippets/visualbasic/System.Globalization/CultureInfo/InvariantCulture/persist1.vb" id="Snippet1":::
+
+## Security decisions
+
+If you are making a security decision (such as whether to allow access to a system resource) based on the result of a string comparison or a case change, you should not use the invariant culture. Instead, you should perform a case-sensitive or case-insensitive ordinal comparison by calling a method that includes a parameter and supplying either or as an argument. Code that performs culture-sensitive string operations can cause security vulnerabilities if the current culture is changed or if the culture on the computer that is running the code differs from the culture that is used to test the code. In contrast, an ordinal comparison depends solely on the binary value of the compared characters.
+
+ ]]>
+
diff --git a/xml/System.Globalization/DateTimeFormatInfo.xml b/xml/System.Globalization/DateTimeFormatInfo.xml
index 041838113a5..ed9380c6d42 100644
--- a/xml/System.Globalization/DateTimeFormatInfo.xml
+++ b/xml/System.Globalization/DateTimeFormatInfo.xml
@@ -78,7 +78,364 @@
Provides culture-specific information about the format of date and time values.
- For more information about this API, see Supplemental API remarks for DateTimeFormatInfo.
+
+ class contain culture-specific information for formatting or parsing date and time values such as the following:
+
+- The patterns used to format date values.
+- The patterns used to format time values.
+- The names of the days of the week.
+- The names of the months of the year.
+- The A.M. and P.M. designators used in time values.
+- The calendar in which dates are expressed.
+
+## Instantiate a DateTimeFormatInfo object
+
+A object can represent the formatting conventions of the invariant culture, a specific culture, a neutral culture, or the current culture. This section discusses how to instantiate each type of object.
+
+### Instantiate a DateTimeFormatInfo object for the invariant culture
+
+The invariant culture represents a culture that is culture-insensitive. It is based on the English language, but not on any specific English-speaking country/region. Although the data of specific cultures can be dynamic and can change to reflect new cultural conventions or user preferences, the data of the invariant culture does not change. You can instantiate a object that represents the formatting conventions of the invariant culture in the following ways:
+
+- By retrieving the value of the property. The returned object is read-only.
+- By calling the parameterless constructor. The returned object is read/write.
+- By retrieving the value of the property from the object that is returned by the property. The returned object is read-only.
+
+The following example uses each of these methods to instantiate a object that represents the invariant culture. It then indicates whether the object is read-only.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs" id="Snippet1":::
+
+### Instantiate a DateTimeFormatInfo object for a specific culture
+
+A specific culture represents a language that is spoken in a particular country/region. For example, en-US is a specific culture that represents the English language spoken in the United States, and en-CA is a specific culture that represents the English language spoken in Canada. You can instantiate a object that represents the formatting conventions of a specific culture in the following ways:
+
+- By calling the method and retrieving the value of the returned object's property. The returned object is read-only.
+
+- By passing the static method a object that represents the culture whose object you want to retrieve. The returned object is read/write.
+
+- By calling the static method and retrieving the value of the returned object's property. The returned object is read/write.
+
+- By calling the class constructor and retrieving the value of the returned object's property. The returned object is read/write.
+
+The following example illustrates each of these ways to instantiate a object and indicates whether the resulting object is read-only.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs" id="Snippet3":::
+
+### Instantiate a DateTimeFormatInfo object for a neutral culture
+
+A neutral culture represents a culture or language that is independent of a country/region; it is typically the parent of one or more specific cultures. For example, Fr is a neutral culture for the French language and the parent of the fr-FR culture. You can instantiate a object that represents the formatting conventions of a neutral culture in the same ways that you create a object that represents the formatting conventions of a specific culture. In addition, you can retrieve a neutral culture's object by retrieving a neutral culture from a specific culture's property and retrieving the object returned by its property. Unless the parent culture represents the invariant culture, the returned object is read/write. The following example illustrates these ways of instantiating a object that represents a neutral culture.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/create1.cs" id="Snippet2":::
+
+However, a neutral culture lacks culture-specific formatting information, because it is independent of a specific country/region. Instead of populating the object with generic values, .NET returns a object that reflects the formatting conventions of a specific culture that is a child of the neutral culture. For example, the object for the neutral en culture reflects the formatting conventions of the en-US culture, and the object for the fr culture reflects the formatting conventions of the fr-FR culture.
+
+You can use code like the following to determine which specific culture's formatting conventions a neutral culture represents. The example uses reflection to compare the properties of a neutral culture with the properties of a specific child culture. It considers two calendars to be equivalent if they are the same calendar type and, for Gregorian calendars, if their properties have identical values.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate6.cs" id="Snippet6":::
+
+### Instantiate a DateTimeFormatInfo object for the current culture
+
+You can instantiate a object that represents the formatting conventions of the current culture in the following ways:
+
+- By retrieving the value of the property. The returned object is read-only.
+
+- By retrieving the value of the property from the object that is returned by the property. The returned object is read-only.
+
+- By calling the method with a object that represents the current culture. The returned object is read-only.
+
+The following example uses each of these methods to instantiate a object that represents the formatting conventions of the current culture. It then indicates whether the object is read-only.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/create2.cs" id="Snippet4":::
+
+You can create a writable object that represents the conventions of the current culture in one of these ways:
+
+- By retrieving a object in any of the three previous ways and calling the method on the returned object. This creates a copy of the original object, except that its property is `false`.
+
+- By calling the method to create a object that represents the current culture, and then using its property to retrieve the object.
+
+The following example illustrates each way of instantiating a read/write object and displays the value of its property.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate2.cs" id="Snippet7":::
+
+In Windows, the user can override some of the property values used in formatting and parsing operations through the **Region and Language** application in Control Panel. For example, a user whose culture is English (United States) might choose to display long time values using a 24-hour clock (in the format HH:mm:ss) instead of the default 12-hour clock (in the format h:mm:ss tt). The objects retrieved in the ways discussed previously all reflect these user overrides. If this is undesirable, you can create a object that does not reflect user overrides (and is also read/write instead of read-only) by calling the constructor and supplying a value of `false` for the `useUserOverride` argument. The following example illustrates this for a system whose current culture is English (United States) and whose long time pattern has been changed from the default of h:mm:ss tt to HH:mm:ss.
+
+:::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/instantiate3.cs" id="Snippet8":::
+
+## DateTimeFormatInfo and dynamic data
+
+The culture-specific data for formatting date and time values provided by the class is dynamic, just like cultural data provided by the class. You should not make any assumptions about the stability of values for objects that are associated with particular objects. Only the data provided by the invariant culture and its associated object is stable. Other data can change between application sessions or even while your application is running. There are four major sources of change:
+
+- System updates. Cultural preferences such as the preferred calendar or customary date and time formats change over time. When this happens, Windows Update includes changes to the property value for a particular culture.
+
+- Replacement cultures. The class can be used to replace the data of an existing culture.
+
+- Cascading changes to property values. A number of culture-related properties can change at runtime, which, in turn, causes data to change. For example, the current culture can be changed either programmatically or through user action. When this happens, the object returned by the property changes to an object associated with the current culture. Similarly, a culture's calendar can change, which can result in changes to numerous property values.
+
+- User preferences. Users of your application might choose to override some of the values associated with the current system culture through the regional and language options in Control Panel. For example, users might choose to display the date in a different format. If the property is set to `true`, the properties of the object is also retrieved from the user settings. If the user settings are incompatible with the culture associated with the object (for example, if the selected calendar is not one of the calendars indicated by the property), the results of the methods and the values of the properties are undefined.
+
+To minimize the possibility of inconsistent data, all user-overridable properties of a object are initialized when the object is created. There is still a possibility of inconsistency, because neither object creation nor the user override process is atomic and the relevant values can change during object creation. However, this situation should be extremely rare.
+
+You can control whether user overrides are reflected in objects that represent the same culture as the system culture. The following table lists the ways in which a object can be retrieved and indicates whether the resulting object reflects user overrides.
+
+|Source of CultureInfo and DateTimeFormatInfo object|Reflects user overrides|
+|---------------------------------------------------------|-----------------------------|
+|`CultureInfo.CurrentCulture.DateTimeFormat` property|Yes|
+| property|Yes|
+| method|Yes|
+| method|No|
+| constructor|Yes|
+| constructor|Depends on value of `useUserOverride` parameter|
+
+Unless there is a compelling reason to do otherwise, you should respect user overrides when you use the object in client applications to format and parse user input or to display data. For server applications or unattended applications, you should not. However, if you are using the object either explicitly or implicitly to persist date and time data in string form, you should either use a object that reflects the formatting conventions of the invariant culture, or you should specify a custom date and time format string that you use regardless of culture.
+
+## Format dates and times
+
+A object is used implicitly or explicitly in all date and time formatting operations. These include calls to the following methods:
+
+- All date and time formatting methods, such as