Επεξεργασία

Κοινή χρήση μέσω


RegionInfo Class

Definition

Contains information about the country/region.

public ref class RegionInfo
public class RegionInfo
[System.Serializable]
public class RegionInfo
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class RegionInfo
type RegionInfo = class
[<System.Serializable>]
type RegionInfo = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type RegionInfo = class
Public Class RegionInfo
Inheritance
RegionInfo
Attributes

Examples

The following example demonstrates several members of the RegionInfo class.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Displays the property values of the RegionInfo for "US".
   RegionInfo^ myRI1 = gcnew 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 = gcnew RegionInfo( (gcnew 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.

*/
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.

*/
Imports System.Globalization


Public Class SamplesRegionInfo   

   Public Shared Sub Main()

      ' Displays the property values of the RegionInfo for "US".
      Dim myRI1 As 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.
      Dim myRI2 As New RegionInfo(New CultureInfo("en-US", False).LCID)
      If myRI1.Equals(myRI2) Then
         Console.WriteLine("The two RegionInfo instances are equal.")
      Else
         Console.WriteLine("The two RegionInfo instances are NOT equal.")
      End If 

   End Sub

End Class


'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.

Remarks

For more information about this API, see Supplemental API remarks for RegionInfo.

Constructors

RegionInfo(Int32)

Initializes a new instance of the RegionInfo class based on the country/region associated with the specified culture identifier.

RegionInfo(String)

Initializes a new instance of the RegionInfo class based on the country/region or specific culture, specified by name.

Properties

CurrencyEnglishName

Gets the name, in English, of the currency used in the country/region.

CurrencyNativeName

Gets the name of the currency used in the country/region, formatted in the native language of the country/region.

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 .NET.

EnglishName

Gets the full name of the country/region in English.

GeoId

Gets a unique identification number for a geographical region, country, city, or location.

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.

ThreeLetterISORegionName

Gets the three-letter code defined in ISO 3166 for the country/region.

ThreeLetterWindowsRegionName

Gets the three-letter code assigned by Windows to the country/region represented by this RegionInfo.

TwoLetterISORegionName

Gets the two-letter code defined in ISO 3166 for the country/region.

Methods

Equals(Object)

Determines whether the specified object is the same instance as the current RegionInfo.

GetHashCode()

Serves as a hash function for the current RegionInfo, suitable for hashing algorithms and data structures, such as a hash table.

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 codes specified for the current RegionInfo.

Applies to

See also