Country Class
Provides utilities for working with countries and region information.
public static class CountryExample
var region = new RegionInfo("US");
string flag = Country.GetUnicodeFlag(region);
Assert.Equal("\U0001F1FA\U0001F1F8", flag); // US flag emoji
string flag2 = Country.GetUnicodeFlag("FR");
Assert.Equal("\U0001F1EB\U0001F1F7", flag2); // FR flag emojiMethods
| Name | Description |
|---|---|
| GetUnicodeFlag(RegionInfo) | Gets the Unicode flag emoji for the specified region. |
| GetUnicodeFlag(string) | Gets the Unicode flag emoji for the specified two-letter ISO region code. |
| TryGetUnicodeFlag(RegionInfo?, string?) | Tries to get the Unicode flag emoji for the specified region. |
| TryGetUnicodeFlag(string?, string?) | Tries to get the Unicode flag emoji for the specified two-letter ISO region code. |
GetUnicodeFlag overloads
GetUnicodeFlag(RegionInfo)
Country.csGets the Unicode flag emoji for the specified region.
public static string GetUnicodeFlag(RegionInfo region)Parameters
regionRegionInfo
Returns
Exceptions
ArgumentException- The two-letter ISO region name of
regionis not made of two ASCII letters, such as419fores-419.
GetUnicodeFlag(string)
Country.csGets the Unicode flag emoji for the specified two-letter ISO region code.
Parameters
twoLetterISORegionNamestring
Returns
Exceptions
ArgumentExceptiontwoLetterISORegionNameis not made of two ASCII letters.
TryGetUnicodeFlag overloads
TryGetUnicodeFlag(RegionInfo?, string?)
Country.csTries to get the Unicode flag emoji for the specified region.
public static bool TryGetUnicodeFlag(RegionInfo? region, out string? flag)Parameters
regionRegionInfo?flagstring?
Returns
bool true if region is not null and its two-letter ISO region name is made of two ASCII letters; otherwise, false.
TryGetUnicodeFlag(string?, string?)
Country.csTries to get the Unicode flag emoji for the specified two-letter ISO region code.