I am trying using c# to get the country name from a country code
For example :
fr-fr
gets me Franceit-it
gets me ItalyThe problem with my code is that I am not getting the name but a information like this :
French (France)
This is my code :
var cultureInfo = new CultureInfo("fr-fr");
var result : cultureInfo.EnglishName
My result is "French (France)"
instead of France.
I have managed to get what I want by use the parent property of the cultureInfo but I am not sure if it's a good method.
Because CultureInfo.EnglishName
still returns culture name.
You can create a RegionInfo
based on this culture and call it's EnglishName
property as well.
var cultureInfo = new CultureInfo("fr-fr");
var ri = new RegionInfo(cultureInfo.Name);
ri.EnglishName // France
or
var cultureInfo = new CultureInfo("it-it");
var ri = new RegionInfo(cultureInfo.Name);
ri.EnglishName // Italy
You can get country name this way
RegionInfo cultureInfo = new RegionInfo("fr-fr");
string result = cultureInfo.EnglishName;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With