RegionInfo Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Contains information about a country/region.
Inheritance Hierarchy
System.Object
System.Globalization.RegionInfo
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<ComVisibleAttribute(True)> _
Public Class RegionInfo
[ComVisibleAttribute(true)]
public class RegionInfo
The RegionInfo type exposes the following members.
Constructors
Name | Description | |
---|---|---|
RegionInfo | Initializes a new instance of the RegionInfo class for a particular country/region based on its full culture name. |
Top
Properties
Name | Description | |
---|---|---|
CurrencySymbol | Gets the currency symbol associated with the country/region. | |
CurrentRegion | Gets the RegionInfo that represents the country/region used by the current thread. | |
DisplayName | Gets the full name of the country/region in the language of the localized version of the .NET Framework for Silverlight. | |
EnglishName | Gets the full name of the country/region in English. | |
IsMetric | Gets a value indicating whether the country/region uses the metric system for measurements. | |
ISOCurrencySymbol | Gets the three-character ISO 4217 currency symbol associated with the country/region. | |
Name | Gets the name or ISO 3166 two-letter country/region code for the current RegionInfo object. | |
NativeName | Gets the name of a country/region formatted in the native language of the country/region. | |
TwoLetterISORegionName | Gets the two-letter code defined in ISO 3166 for the country/region. |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is the same as the current RegionInfo object. (Overrides Object.Equals(Object).) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for the current RegionInfo, suitable for hashing algorithms and data structures, such as a hash table. (Overrides Object.GetHashCode().) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string containing the culture name or ISO 3166 two-letter country/region code specified for the current RegionInfo. (Overrides Object.ToString().) |
Top
Remarks
In contrast to CultureInfo, RegionInfo does not represent user preferences 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 a country/region. Case is not significant. The Name and TwoLetterISORegionName properties retrieve the appropriate codes in uppercase.
Note: |
---|
Although a RegionInfo object is identified by a two-letter country/region code, that two-letter code cannot be used to instantiate a new RegionInfo object. Instead, to instantiate a new RegionInfo object, a full culture name must be passed to its class constructor. A full culture name combines a language code with a country or region code, such as "en-US", "zh-Hans", and "eu-ES". |
The following is a list of the predefined RegionInfo names that are recognized by this class and other classes in the System.Globalization namespace.
ISO 3166 2-letter code |
Country/region |
---|---|
AE |
United Arab Emirates |
AL |
Albania |
AM |
Armenia |
AR |
Argentina |
AT |
Austria |
AU |
Australia |
AZ |
Azerbaijan |
BE |
Belgium |
BG |
Bulgaria |
BH |
Bahrain |
BN |
Brunei |
BO |
Bolivia |
BR |
Brazil |
BY |
Belarus |
BZ |
Belize |
CA |
Canada |
CB |
Caribbean |
CH |
Switzerland |
CL |
Chile |
CN |
China |
CO |
Colombia |
CR |
Costa Rica |
CZ |
Czech Republic |
DE |
Germany |
DK |
Denmark |
DO |
Dominican Republic |
DZ |
Algeria |
EC |
Ecuador |
EE |
Estonia |
EG |
Egypt |
ES |
Spain |
FI |
Finland |
FO |
Faroe Islands |
FR |
France |
GB |
United Kingdom |
GE |
Georgia |
GR |
Greece |
GT |
Guatemala |
HK |
Hong Kong SAR |
HN |
Honduras |
HR |
Croatia |
HU |
Hungary |
ID |
Indonesia |
IE |
Ireland |
IL |
Israel |
IN |
India |
IQ |
Iraq |
IR |
Iran |
IS |
Iceland |
IT |
Italy |
JM |
Jamaica |
JO |
Jordan |
JP |
Japan |
KE |
Kenya |
KG |
Kyrgyzstan |
KR |
Korea |
KW |
Kuwait |
KZ |
Kazakhstan |
LB |
Lebanon |
LI |
Liechtenstein |
LT |
Lithuania |
LU |
Luxembourg |
LV |
Latvia |
LY |
Libya |
MA |
Morocco |
MC |
Monaco |
MK |
FYROM |
MN |
Mongolia |
MO |
Macao SAR |
MV |
Maldives |
MX |
Mexico |
MY |
Malaysia |
ME |
Montenegro |
NI |
Nicaragua |
NL |
The Netherlands |
NO |
Norway |
NZ |
New Zealand |
OM |
Oman |
PA |
Panama |
PE |
Peru |
PH |
Philippines |
PK |
Pakistan |
PL |
Poland |
PR |
Puerto Rico |
PT |
Portugal |
PY |
Paraguay |
QA |
Qatar |
RO |
Romania |
RS |
Serbia |
RU |
Russia |
SA |
Saudi Arabia |
SE |
Sweden |
SG |
Singapore |
SI |
Slovenia |
SK |
Slovakia |
SV |
El Salvador |
SY |
Syria |
TH |
Thailand |
TN |
Tunisia |
TR |
Turkey |
TT |
Trinidad and Tobago |
TW |
Taiwan |
UA |
Ukraine |
US |
United States |
UY |
Uruguay |
UZ |
Uzbekistan |
VE |
Venezuela |
VN |
Vietnam |
YE |
Yemen |
ZA |
South Africa |
ZW |
Zimbabwe |
Examples
The following code example demonstrates several members of the RegionInfo class.
Imports System.Globalization
Public Class Example
Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
' Display RegionInfo property values.
Dim myRI1 As New RegionInfo("en-US")
outputBlock.Text += String.Format(" Name: {0}", myRI1.Name) & vbCrLf
outputBlock.Text += String.Format(" DisplayName: {0}", myRI1.DisplayName) & vbCrLf
outputBlock.Text += String.Format(" EnglishName: {0}", myRI1.EnglishName) & vbCrLf
outputBlock.Text += String.Format(" IsMetric: {0}", myRI1.IsMetric) & vbCrLf
outputBlock.Text += String.Format(" TwoLetterISORegionName: {0}", myRI1.TwoLetterISORegionName) & vbCrLf
outputBlock.Text += String.Format(" CurrencySymbol: {0}", myRI1.CurrencySymbol) & vbCrLf
outputBlock.Text += String.Format(" ISOCurrencySymbol: {0}", myRI1.ISOCurrencySymbol) & vbCrLf
outputBlock.Text &= vbCrLf
' Compare this RegionInfo with another RegionInfo.
Dim myRI2 As New RegionInfo(New CultureInfo("es-US").Name)
If myRI1.Equals(myRI2) Then
outputBlock.Text &= "The two RegionInfo instances are equal." & vbCrLf
Else
outputBlock.Text &= "The two RegionInfo instances are NOT equal." & vbCrLf
End If
End Sub
End Class
' The example displays 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.
using System;
using System.Globalization;
public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
// Display RegionInfo property values.
RegionInfo myRI1 = new RegionInfo("en-US");
outputBlock.Text += String.Format(" Name: {0}", myRI1.Name) + "\n";
outputBlock.Text += String.Format(" DisplayName: {0}", myRI1.DisplayName) + "\n";
outputBlock.Text += String.Format(" EnglishName: {0}", myRI1.EnglishName) + "\n";
outputBlock.Text += String.Format(" IsMetric: {0}", myRI1.IsMetric) + "\n";
outputBlock.Text += String.Format(" TwoLetterISORegionName: {0}", myRI1.TwoLetterISORegionName) + "\n";
outputBlock.Text += String.Format(" CurrencySymbol: {0}", myRI1.CurrencySymbol) + "\n";
outputBlock.Text += String.Format(" ISOCurrencySymbol: {0}", myRI1.ISOCurrencySymbol) + "\n";
outputBlock.Text += "\n";
// Compare this RegionInfo with another RegionInfo.
RegionInfo myRI2 = new RegionInfo("en-US");
if (myRI1.Equals(myRI2))
outputBlock.Text += "The two RegionInfo instances are equal." + "\n";
else
outputBlock.Text += "The two RegionInfo instances are NOT equal." + "\n";
}
}
// The example displays the following output.
// Name: US
// DisplayName: United States
// EnglishName: United States
// IsMetric: False
// TwoLetterISORegionName: US
// CurrencySymbol: $
// ISOCurrencySymbol: USD
// The two RegionInfo instances are equal.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.