RegionInfo 类

定义

包含国家/地区的相关信息。

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
继承
RegionInfo
属性

示例

以下示例演示 类的 RegionInfo 多个成员。

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.

注解

有关此 API 的详细信息,请参阅 RegionInfo 的补充 API 说明

构造函数

RegionInfo(Int32)

基于与指定的区域性标识符关联的国家/地区初始化 RegionInfo 类的一个新实例。

RegionInfo(String)

基于按名称指定的国家/地区或特定区域性初始化 RegionInfo 类的一个新实例。

属性

CurrencyEnglishName

获取该国家/地区中使用的货币的英文名称。

CurrencyNativeName

获取该国家/地区中使用的货币名称,它使用该国家/地区的本地语言格式表示。

CurrencySymbol

获取与国家/地区关联的货币符号。

CurrentRegion

获取表示当前线程所使用的国家/地区的 RegionInfo

DisplayName

获取以 .NET 本地化版本语言表示的国家/地区的全名。

EnglishName

获取以英文表示的国家/地区的全名。

GeoId

获取地理区域、国家/地区、城市或地点的唯一标识号。

IsMetric

获取一个值,该值指示该国家/地区是否使用公制进行度量。

ISOCurrencySymbol

获取与国家/地区关联的由三个字符组成的 ISO 4217 货币符号。

Name

获取当前 RegionInfo 对象的名称或 ISO 3166 双字母国家/地区代码。

NativeName

获取一个国家/地区的名称,它使用该国家/地区的本地语言格式表示。

ThreeLetterISORegionName

获取在 ISO 3166 中定义的由三个字母组成的国家/地区代码。

ThreeLetterWindowsRegionName

获取 Windows 分配给此 RegionInfo 所表示国家/地区的由三个字母组成的代码。

TwoLetterISORegionName

获取在 ISO 3166 中定义的由两个字母组成的国家/地区代码。

方法

Equals(Object)

确定指定的对象与当前 RegionInfo 是否为同一实例。

GetHashCode()

用作当前 RegionInfo 的哈希函数,适合用在哈希算法和数据结构(如哈希表)中。

GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回一个字符串,它包含区域性名称或 ISO 3166 中为当前 RegionInfo 指定的双字母国家/地区代码。

适用于

另请参阅