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()

傳回字串,其中包含針對目前 RegionInfo 所指定的文化特性名稱或 ISO 3166 兩個字母國家/地區代碼。

適用於

另請參閱