In db I already have stored values with RegionInfo.TwoLetterISORegionName values. Atm I have values like 'be' for Belgium, 'no', 'gb', 'en' etc.
If I write:
var culture = new CultureInfo("be");
instead of Belgium, I get Belarus.
So I need a way to get CultureInfo from RegionInfo.TwoLetterISORegionName.
Given a two letter region name, there are multiple cultures that can be associated with that region name (because in a country multiple languages can be spoken). For example for Switzerland there are 4 cultures: de, fr, it, rm.
And now some code:
The code returns a
ILookup<string, CultureInfo>
(consider it to be aIDictionary<string, IEnumerable<CultureInfo>>
).Use it like:
and then:
Note that a
ILookup<,>
won't throw an exception if used with a non-existing key:rtoc["aaaaa"]
will simply return an emptyIEnumerable<>
.