Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

RegionInfo Class

Contains information about the country/region.

System.Object
  System.Globalization.RegionInfo

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class RegionInfo

The RegionInfo type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkRegionInfo(Int32)Initializes a new instance of the RegionInfo class based on the country/region associated with the specified culture identifier.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryRegionInfo(String)Initializes a new instance of the RegionInfo class based on the country/region or specific culture, specified by name.
Top
  NameDescription
Public propertyCurrencyEnglishNameGets the name, in English, of the currency used in the country/region.
Public propertyCurrencyNativeNameGets the name of the currency used in the country/region, formatted in the native language of the country/region.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryCurrencySymbolGets the currency symbol associated with the country/region.
Public propertyStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryCurrentRegionGets the RegionInfo that represents the country/region used by the current thread.
Public propertyDisplayNameGets the full name of the country/region in the language of the localized version of .NET Framework.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryEnglishNameGets the full name of the country/region in English.
Public propertyGeoIdGets a unique identification number for a geographical region, country, city, or location.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryIsMetricGets a value indicating whether the country/region uses the metric system for measurements.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryISOCurrencySymbolGets the three-character ISO 4217 currency symbol associated with the country/region.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryNameGets the name or ISO 3166 two-letter country/region code for the current RegionInfo object.
Public propertyNativeNameGets the name of a country/region formatted in the native language of the country/region.
Public propertySupported by the XNA FrameworkThreeLetterISORegionNameGets the three-letter code defined in ISO 3166 for the country/region.
Public propertySupported by the XNA FrameworkThreeLetterWindowsRegionNameGets the three-letter code assigned by Windows to the country/region represented by this RegionInfo.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibraryTwoLetterISORegionNameGets the two-letter code defined in ISO 3166 for the country/region.
Top
  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryEqualsDetermines whether the specified object is the same instance as the current RegionInfo. (Overrides Object.Equals(Object).)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibraryFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetHashCodeServes as a hash function for the current RegionInfo, suitable for hashing algorithms and data structures, such as a hash table. (Overrides Object.GetHashCode().)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibraryMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryToStringReturns a string containing the culture name or ISO 3166 two-letter country/region codes specified for the current RegionInfo. (Overrides Object.ToString().)
Top

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 return the appropriate codes in uppercase. For the current list of RegionInfo names, see English country names and code elements on the ISO Web site.

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. RegionInfo properties (for example, 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 that have 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 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.

*/


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.