RegionInfo Class
Contains information about the country/region.
Assembly: mscorlib (in mscorlib.dll)
In contrast to CultureInfo, RegionInfo does not represent preferences of the user and does not depend on the user's language or culture.
The RegionInfo name is one of the two-letter codes defined in ISO 3166 for country/region. Case is not significant. The Name, TwoLetterISORegionName, and ThreeLetterISORegionName properties retrieve the appropriate codes in uppercase.
The following is a list of the predefined RegionInfo names accepted and used by this class and other classes in the System.Globalization namespace.
|
ISO 3166 2-letter code |
ISO 3166 3-letter code |
Country/region |
|---|---|---|
|
AE |
ARE |
United Arab Emirates |
|
AL |
ALB |
Albania |
|
AM |
ARM |
Armenia |
|
AR |
ARG |
Argentina |
|
AT |
AUT |
Austria |
|
AU |
AUS |
Australia |
|
AZ |
AZE |
Azerbaijan |
|
BE |
BEL |
Belgium |
|
BG |
BGR |
Bulgaria |
|
BH |
BHR |
Bahrain |
|
BN |
BRN |
Brunei |
|
BO |
BOL |
Bolivia |
|
BR |
BRA |
Brazil |
|
BY |
BLR |
Belarus |
|
BZ |
BLZ |
Belize |
|
CA |
CAN |
Canada |
|
"029" |
"029" |
Caribbean |
|
CH |
CHE |
Switzerland |
|
CL |
CHL |
Chile |
|
CN |
CHN |
China |
|
CO |
COL |
Colombia |
|
CR |
CRI |
Costa Rica |
|
CZ |
CZE |
Czech Republic |
|
DE |
DEU |
Germany |
|
DK |
DNK |
Denmark |
|
DO |
DOM |
Dominican Republic |
|
DZ |
DZA |
Algeria |
|
EC |
ECU |
Ecuador |
|
EE |
EST |
Estonia |
|
EG |
EGY |
Egypt |
|
ES |
ESP |
Spain |
|
FI |
FIN |
Finland |
|
FO |
FRO |
Faroe Islands |
|
FR |
FRA |
France |
|
GB |
GBR |
United Kingdom |
|
GE |
GEO |
Georgia |
|
GR |
GRC |
Greece |
|
GT |
GTM |
Guatemala |
|
HK |
HKG |
Hong Kong SAR |
|
HN |
HND |
Honduras |
|
HR |
HRV |
Croatia |
|
HU |
HUN |
Hungary |
|
ID |
IDN |
Indonesia |
|
IE |
IRL |
Ireland |
|
IL |
ISR |
Israel |
|
IN |
IND |
India |
|
IQ |
IRQ |
Iraq |
|
IR |
IRN |
Iran |
|
IS |
ISL |
Iceland |
|
IT |
ITA |
Italy |
|
JM |
JAM |
Jamaica |
|
JO |
JOR |
Jordan |
|
JP |
JPN |
Japan |
|
KE |
KEN |
Kenya |
|
KG |
KGZ |
Kyrgyzstan |
|
KR |
KOR |
Korea |
|
KW |
KWT |
Kuwait |
|
KZ |
KAZ |
Kazakhstan |
|
LB |
LBN |
Lebanon |
|
LI |
LIE |
Liechtenstein |
|
LT |
LTU |
Lithuania |
|
LU |
LUX |
Luxembourg |
|
LV |
LVA |
Latvia |
|
LY |
LBY |
Libya |
|
MA |
MAR |
Morocco |
|
MC |
MCO |
Monaco |
|
MK |
MKD |
Macedonia (FYROM) |
|
MN |
MNG |
Mongolia |
|
MO |
MAC |
Macao SAR |
|
MV |
MDV |
Maldives |
|
MX |
MEX |
Mexico |
|
MY |
MYS |
Malaysia |
|
NI |
NIC |
Nicaragua |
|
NL |
NLD |
The Netherlands |
|
NO |
NOR |
Norway |
|
NZ |
NZL |
New Zealand |
|
OM |
OMN |
Oman |
|
PA |
PAN |
Panama |
|
PE |
PER |
Peru |
|
PH |
PHL |
Philippines |
|
PK |
PAK |
Pakistan |
|
PL |
POL |
Poland |
|
PR |
PRI |
Puerto Rico |
|
PT |
PRT |
Portugal |
|
PY |
PRY |
Paraguay |
|
QA |
QAT |
Qatar |
|
RO |
ROM |
Romania |
|
RU |
RUS |
Russia |
|
SA |
SAU |
Saudi Arabia |
|
SE |
SWE |
Sweden |
|
SG |
SGP |
Singapore |
|
SI |
SVN |
Slovenia |
|
SK |
SVK |
Slovakia |
|
SP |
SRB |
Serbia |
|
SV |
SLV |
El Salvador |
|
SY |
SYR |
Syria |
|
TH |
THA |
Thailand |
|
TN |
TUN |
Tunisia |
|
TR |
TUR |
Turkey |
|
TT |
TTO |
Trinidad and Tobago |
|
TW |
TWN |
Taiwan |
|
UA |
UKR |
Ukraine |
|
US |
USA |
United States |
|
UY |
URY |
Uruguay |
|
UZ |
UZB |
Uzbekistan |
|
VE |
VEN |
Venezuela |
|
VN |
VNM |
Vietnam |
|
YE |
YEM |
Yemen |
|
ZA |
ZAF |
South Africa |
|
ZW |
ZWE |
Zimbabwe |
When possible, you should use specific culture names -- for example, en-US for English (United States) -- when you instantiate a RegionInfo object. You can use just a country/region name, such as "US", in the class constructor. However, this technique does not always yield appropriate results. The RegionInfo properties, for instance, DisplayName, depend on culture names for both the language and the country/region. Here are some scenarios in which you should use culture names instead of just country/region names:
-
When the language name is of primary importance. For example, for the "es-US" culture name on Windows Vista, an application probably requires a display name of "Estados Unidos" instead of "United States". Therefore it needs to work with the culture name instead of the country/region name alone, which yields "United States" regardless of the language.
-
When script differences must be considered. For example, the country/region "AZ" deals with Azerbaijani cultures having the names az-Latn-AZ and az-Cyrl-AZ, and the Latin and Cyrillic scripts can be very different for this country/region.
-
When maintenance of detail is important. For a specific culture such as English (United States, named "en-US", your application can lose important information if it tries to create a new RegionInfo object from just the neutral culture name "en" or the country/region name "US".
The following code example demonstrates several members of the RegionInfo class.
using System; using System.Globalization; public class SamplesRegionInfo { public static void Main() { // Displays the property values of the RegionInfo for "US". RegionInfo myRI1 = new RegionInfo( "US" ); Console.WriteLine( " Name: {0}", myRI1.Name ); Console.WriteLine( " DisplayName: {0}", myRI1.DisplayName ); Console.WriteLine( " EnglishName: {0}", myRI1.EnglishName ); Console.WriteLine( " IsMetric: {0}", myRI1.IsMetric ); Console.WriteLine( " ThreeLetterISORegionName: {0}", myRI1.ThreeLetterISORegionName ); Console.WriteLine( " ThreeLetterWindowsRegionName: {0}", myRI1.ThreeLetterWindowsRegionName ); Console.WriteLine( " TwoLetterISORegionName: {0}", myRI1.TwoLetterISORegionName ); Console.WriteLine( " CurrencySymbol: {0}", myRI1.CurrencySymbol ); Console.WriteLine( " ISOCurrencySymbol: {0}", myRI1.ISOCurrencySymbol ); Console.WriteLine(); // Compares the RegionInfo above with another RegionInfo created using CultureInfo. RegionInfo myRI2 = new RegionInfo( new CultureInfo("en-US",false).LCID ); if ( myRI1.Equals( myRI2 ) ) Console.WriteLine( "The two RegionInfo instances are equal." ); else Console.WriteLine( "The two RegionInfo instances are NOT equal." ); } } /* This code produces the following output. Name: US DisplayName: United States EnglishName: United States IsMetric: False ThreeLetterISORegionName: USA ThreeLetterWindowsRegionName: USA TwoLetterISORegionName: US CurrencySymbol: $ ISOCurrencySymbol: USD The two RegionInfo instances are equal. */
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
This class do not follow ISO 3166 standard regarding Serbia. The correct 2-letter country code should be 'RS' and NOT as you define it 'SP'. When will this be fixed?
It is addressed in the .NET Framework 4.
- 12/5/2008
- Xxavante
- 5/5/2010
- R Petrusha - MSFT
The currency symbol for Romania is no longer "ROL". It's "RON" now.
Documentation to Be Updated
The documentation for the RegionInfo.ISOCurrencySymbol property in the .NET Framework Version 4 at http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.isocurrencysymbol.aspx will be updated to reflect this change.
--Ron Petrusha
Developer Division User Education
Microsoft Corporation
- 5/10/2009
- Andrei Rinea
- 5/5/2010
- R Petrusha - MSFT
<#
.SYNOPSIS
This script displays the property values for a globalisation region
.DESCRIPTION
This script
.NOTES
File Name : get-regioninfo.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2 CTP3
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN Sample posted at:
http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.aspx
.EXAMPLE
PSH [C:\foo]: .\get-regioninfo.ps1'
Name: US
DisplayName: United States
EnglishName: United States
IsMetric: False
ThreeLetterISORegionName: USA
ThreeLetterWindowsRegionName: USA
TwoLetterISORegionName: US
CurrencySymbol: $
ISOCurrencySymbol: USD
The two RegionInfo instances are equal.
#>
##
# start of script
##
# greate a region
$myRI1 = New-Object System.Globalization.RegionInfo "US"
" Name: {0}" -f $myRI1.Name
" DisplayName: {0}" -f $myRI1.DisplayName
" EnglishName: {0}" -f $myRI1.EnglishName
" IsMetric: {0}" -f $myRI1.IsMetric
" ThreeLetterISORegionName: {0}" -f $myRI1.ThreeLetterISORegionName
" ThreeLetterWindowsRegionName: {0}" -f $myRI1.ThreeLetterWindowsRegionName
" TwoLetterISORegionName: {0}" -f $myRI1.TwoLetterISORegionName
" CurrencySymbol: {0}" -f $myRI1.CurrencySymbol
" ISOCurrencySymbol: {0}" -f $myRI1.ISOCurrencySymbol
""
# Compare the RegionInfo above with another RegionInfo created using CultureInfo
$culinfo = New-Object system.Globalization.CultureInfo "en-us", $false
$myRI2 = New-Object System.Globalization.RegionInfo $culinfo.lcid
if ( $myRI1.Equals( $myRI2 )) {
"The two RegionInfo instances are equal."
}
else {
"The two RegionInfo instances are NOT equal."
}
- 5/25/2009
- Thomas Lee
- 10/7/2009
- Alex Angelopoulos