how to find current country csharp

Code Example - how to find current country csharp

                
                        using System.Globalization;
string country = RegionInfo.CurrentRegion.EnglishName;
                    
                
 

csharp get country code

                        
                                var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures).Select(x => new RegionInfo(x.LCID));
var englishRegion = regions.FirstOrDefault(region => region.EnglishName.Contains("United Kingdom"));
var countryAbbrev = englishRegion.TwoLetterISORegionName;
                            
                        
 

Related code examples