CultureAndRegionInfoBuilder 類別

定義

定義新的自訂文化特性,或根據其他文化特性和國家/地區的自訂文化特性。 自訂的文化特性可安裝在電腦上,隨後供電腦上執行的應用程式使用。 此類別無法獲得繼承。

public ref class CultureAndRegionInfoBuilder sealed
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class CultureAndRegionInfoBuilder
[<System.Runtime.InteropServices.ComVisible(false)>]
type CultureAndRegionInfoBuilder = class
Public NotInheritable Class CultureAndRegionInfoBuilder
繼承
CultureAndRegionInfoBuilder
屬性

範例

下列範例會定義自定義 ru-US 文化特性,代表 美國 中的俄文。 此範例會定義自定義文化特性,方法是從俄文 (俄羅斯) CultureInfo 對象和美國 RegionInfo 物件載入設定,然後設定一些 CultureAndRegionInfoBuilder 屬性。 此範例會註冊自定義文化特性,然後將其具現化,並使它成為目前的文化特性。

using System;
using System.Globalization;
using System.Threading;

public class Example
{
   public static void Main()
   {
      // Create a custom culture for ru-US.
      CultureAndRegionInfoBuilder car1 = new CultureAndRegionInfoBuilder("ru-US",
                                             CultureAndRegionModifiers.None);
      car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"));
      car1.LoadDataFromRegionInfo(new RegionInfo("en-US"));

      car1.CultureEnglishName = "Russian (United States)";
      car1.CultureNativeName = "русский (США)";
      car1.CurrencyNativeName = "Доллар (США)";
      car1.RegionNativeName = "США";

      // Register the culture.
      try {
         car1.Register();
      }
      catch (InvalidOperationException) {
         // Swallow the exception: the culture already is registered.
      }

      // Use the custom culture.
      CultureInfo ci = CultureInfo.CreateSpecificCulture("ru-US");
      Thread.CurrentThread.CurrentCulture = ci;
      Console.WriteLine("Current Culture: {0}",
                        Thread.CurrentThread.CurrentCulture.Name);
      Console.WriteLine("Writing System: {0}",
                        Thread.CurrentThread.CurrentCulture.TextInfo);
   }
}
// The example displays the following output:
//     Current Culture: ru-US
//     Writing System: TextInfo - ru-US
Imports System.Globalization
Imports System.Threading

Module Example
   Public Sub Main()
      ' Create a custom culture for ru-US.
      Dim car1 As New CultureAndRegionInfoBuilder("ru-US", CultureAndRegionModifiers.None)
      car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"))
      car1.LoadDataFromRegionInfo(New RegionInfo("en-US"))
      
      car1.CultureEnglishName = "Russian (United States)"
      car1.CultureNativeName = "русский (США)"
      car1.CurrencyNativeName = "Доллар (США)"
      car1.RegionNativeName = "США"

      ' Register the culture.
      Try
         car1.Register()
      Catch e As InvalidOperationException
         ' Swallow the exception: the culture already is registered.
      End Try
      
      ' Use the custom culture.
      Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("ru-US")
      Thread.CurrentThread.CurrentCulture = ci
      Console.WriteLine("Current Culture: {0}", 
                        Thread.CurrentThread.CurrentCulture.Name)
      Console.WriteLine("Writing System: {0}", 
                        Thread.CurrentThread.CurrentCulture.TextInfo)
   End Sub
End Module
' The example displays the following output:
'     Current Culture: ru-US
'     Writing System: TextInfo - ru-US

備註

如需此 API 的詳細資訊,請參閱 CultureAndRegionInfoBuilder 的補充 API 備註

建構函式

CultureAndRegionInfoBuilder(String, CultureAndRegionModifiers)

初始化 CultureAndRegionInfoBuilder 類別的新執行個體。

屬性

AvailableCalendars

取得或設定此 CultureAndRegionInfoBuilder 物件所支援之曆法的陣列。

CompareInfo

取得或設定 CompareInfo 物件,它定義如何比較文化特性的字串。

ConsoleFallbackUICulture

當預設的圖形使用者介面不適當時,為主控台應用程式取得或設定適合的替代使用者介面文化特性。

CultureEnglishName

取得或設定英文的文化特性名稱。

CultureName

取得將建立之文化特性的名稱。

CultureNativeName

取得或設定文化特性名稱,使用文化特性設定所要顯示的格式和語言。

CultureTypes

取得 CultureTypes 值,它描述目前 CultureAndRegionInfoBuilder 物件所表示的文化特性。

CurrencyEnglishName

取得或設定英文的貨幣名稱,這個貨幣是用於目前 CultureAndRegionInfoBuilder 物件所表示的國家/地區。

CurrencyNativeName

取得或設定貨幣的原生名稱,這個貨幣是用於目前 CultureAndRegionInfoBuilder 物件所表示的國家/地區。

GeoId

取得或設定地區、國家、縣市或位置的唯一識別碼。

GregorianDateTimeFormat

取得或設定 DateTimeFormatInfo 物件,此物件會根據西曆定義日期和時間的格式。

IetfLanguageTag

取得或設定文化特性名稱,其格式是根據 RFC 4646 標準<Tags for the Identification of Languages>。

IsMetric

取得或設定值,指出國家/地區是否使用公制系統為度量。

ISOCurrencySymbol

取得或設定與國家/地區關聯之三個字元的 ISO 4217 貨幣符號。

IsRightToLeft

取得或設定與目前 CultureAndRegionInfoBuilder 物件關聯之書寫系統中文字行的主要方向。

KeyboardLayoutId

取得或設定使用中的輸入地區設定識別項。

LCID

取得目前 CultureAndRegionInfoBuilder 物件的文化特性識別項。

NumberFormat

取得或設定 NumberFormatInfo 物件,定義數字、貨幣和百分比在文化特性上適當的顯示格式。

Parent

取得或設定 CultureInfo 物件,表示目前自訂文化特性的父文化特性。

RegionEnglishName

取得或設定國家/地區的完整英文名稱。

RegionName

為目前的 CultureAndRegionInfoBuilder 物件取得國家/地區名稱。

RegionNativeName

取得或設定此自訂文化特性為人們熟知的國家/地區全名。

TextInfo

取得或設定 TextInfo 物件,它定義與此自訂文化特性相關的書寫系統。

ThreeLetterISOLanguageName

取得或設定此自訂文化特性之語言的 ISO 639-2 三個字母代碼。

ThreeLetterISORegionName

取得或設定國家/地區在 ISO 3166 中定義的三個字母代碼。

ThreeLetterWindowsLanguageName

取得或設定在 Windows API 中所定義之語言的三個字母代碼。

ThreeLetterWindowsRegionName

取得或設定 Windows 指派給由目前自訂文化特性所表示之國家/地區的三個字母代碼。

TwoLetterISOLanguageName

取得或設定目前 CultureInfo 物件之語言的 ISO 639-1 兩個字母代碼。

TwoLetterISORegionName

取得或設定國家/地區在 ISO 3166 中定義的兩個字母代碼。

方法

CreateFromLdml(String)

從包含物件表示的指定 XML 檔案,重新組成 CultureAndRegionInfoBuilder 物件。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
LoadDataFromCultureInfo(CultureInfo)

使用指定之 CultureInfo 物件的對應屬性,設定目前 CultureAndRegionInfoBuilder 物件的屬性。

LoadDataFromRegionInfo(RegionInfo)

使用指定之 RegionInfo 物件的對應屬性,設定目前 CultureAndRegionInfoBuilder 物件的屬性。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Register()

將目前的 CultureAndRegionInfoBuilder 物件當做自訂文化特性保存在本機電腦上,並讓應用程式可以使用該文化特性。 必須有系統管理員權限。

Save(String)

將目前 CultureAndRegionInfoBuilder 物件的 XML 表示寫入指定檔案中。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
Unregister(String)

從本機電腦刪除自訂的文化特性。

適用於