When I call
System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.FrameworkCultures).Where(c => c.Name.EndsWith( "CH"))
I get the result:
de-CH
fr-CH
it-CH
but Visual Studio says
[Obsolete("This value has been deprecated. Please use other values in CultureTypes.")]
FrameworkCultures = 0x40
question: what’s the alternative for this to determine the valid cultures of a country?
1
You can use these alternatives:
var examp1 = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.SpecificCultures).Where(c => c.Name.EndsWith("CH"));
var examp2 = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures).Where(c => c.Name.EndsWith("CH"));
By the way you can see details in this link:
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.culturetypes?view=net-8.0
2
As one can see from manual https://learn.microsoft.com/en-us/dotnet/api/system.globalization.culturetypes?view=net-8.0
FrameworkCultures 64
This member is deprecated; using this value with GetCultures(CultureTypes) returns neutral and specific cultures shipped with the .NET Framework 2.0.
(bold is mine)
You, probably, want SpecificCultures
Cultures that are specific to a country/region.
using System.Globalization;
...
var result = CultureInfo
.GetCultures(CultureTypes.SpecificCultures)
.Where(c => c.Name.EndsWith("CH"));
Edit: note, that some extra cultures are added into .Net since .Net 2.0 Framework:
var result = CultureInfo
.GetCultures(CultureTypes.SpecificCultures)
.Where(c => c.Name.EndsWith("CH"))
.Select(c => $"{c,8} : {c.EnglishName}");
Console.Write(string.Join(Environment.NewLine, result));
Output (.Net 8)
de-CH : German (Switzerland)
en-CH : English (Switzerland)
fr-CH : French (Switzerland)
gsw-CH : Swiss German (Switzerland)
it-CH : Italian (Switzerland)
pt-CH : Portuguese (Switzerland)
rm-CH : Romansh (Switzerland)
wae-CH : Walser (Switzerland)
2