CultureInfo 建構函式

定義

CultureInfo 類別的新執行個體初始化。Initializes a new instance of the CultureInfo class.

多載

CultureInfo(Int32)

根據文化特性識別項所指定的文化特性,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier.

CultureInfo(String)

根據名稱所指定的文化特性,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by name.

CultureInfo(Int32, Boolean)

根據文化特性識別項所指定的文化特性,並根據指定是否要使用系統中使用者選取的文化特性設定的布林值,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier and on the Boolean that specifies whether to use the user-selected culture settings from the system.

CultureInfo(String, Boolean)

根據名稱所指定的文化特性,並根據指示是否要從系統中使用使用者選取的文化特性設定的布林值,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by name and on the Boolean that specifies whether to use the user-selected culture settings from the system.

CultureInfo(Int32)

根據文化特性識別項所指定的文化特性,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier.

public:
 CultureInfo(int culture);
public CultureInfo (int culture);
new System.Globalization.CultureInfo : int -> System.Globalization.CultureInfo
Public Sub New (culture As Integer)

參數

culture
Int32

預先定義的 CultureInfo 識別項、現有 LCID 物件的 CultureInfo 屬性,或 Windows 專用文化特性識別項。A predefined CultureInfo identifier, LCID property of an existing CultureInfo object, or Windows-only culture identifier.

例外狀況

culture 小於零。culture is less than zero.

culture 不是有效的文化特性識別項。culture is not a valid culture identifier. 如需詳細資訊,請參閱<呼叫者注意事項>一節。See the Notes to Callers section for more information.

備註

Windows 系統上可用文化特性的預先定義文化特性識別碼會列在windows 支援的語言/區功能變數名稱稱清單中的 [語言標記] 欄中。Predefined culture identifiers for cultures available on Windows system are listed in the Language tag column in the list of language/region names supported by Windows. 文化名稱遵循 BCP 47 定義的標準。Culture names follow the standard defined by BCP 47.

在大部分的情況下,culture 參數會對應至相對應的國家語言支援(NLS)地區設定識別碼。In most cases, the culture parameter is mapped to the corresponding National Language Support (NLS) locale identifier. culture 參數的值會變成新 CultureInfoLCID 屬性值。The value of the culture parameter becomes the value of the LCID property of the new CultureInfo.

我們建議您 CultureInfo.CultureInfo呼叫地區設定名稱的函式,因為地區設定名稱優於 Lcid。We recommend that you call the locale name constructor CultureInfo.CultureInfo, because locale names are preferable to LCIDs. 若為自訂地區設定,則需要地區設定名稱。For custom locales, a locale name is required.

使用者可以選擇透過 [控制台] 的 [地區及語言選項] 部分,覆寫與 Windows 目前文化特性相關聯的一些值。The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. 例如,使用者可能會選擇以不同的格式來顯示日期,或使用文化特性的預設值以外的貨幣。For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. 如果指定的文化特性識別碼符合目前 Windows 文化特性的文化特性識別碼,則此函式會建立使用這些覆寫的 CultureInfo,包括 DateTimeFormat 屬性所傳回之 DateTimeFormatInfo 實例屬性的使用者設定,以及 NumberFormat 屬性所傳回之 NumberFormatInfo 實例的屬性。If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormat property, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. 如果使用者設定與 CultureInfo 相關聯的文化特性不相容(例如,如果選取的行事曆不是其中一個 OptionalCalendars),方法的結果和屬性的值會是未定義的。If the user settings are incompatible with the culture associated with the CultureInfo (for example, if the selected calendar is not one of the OptionalCalendars) the results of the methods and the values of the properties are undefined.

如果指定的文化特性識別碼不符合目前 Windows 文化特性的識別碼,則此函式會建立一個使用指定文化特性之預設值的 CultureInfoIf the specified culture identifier does not match the identifier of the current Windows culture, this constructor creates a CultureInfo that uses the default values for the specified culture.

UseUserOverride 屬性一律設為 trueThe UseUserOverride property is always set to true.

例如,假設阿拉伯文(沙烏地阿拉伯)是目前的 Windows 文化特性,而使用者已將行事曆從回曆變更為西曆。For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.

對於使用歐元的文化特性,.NET Framework 和 Windows XP 會將預設貨幣設定為歐元。For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro. 不過,舊版的 Windows 則不會。However, older versions of Windows do not. 因此,如果舊版 Windows 的使用者未透過 [控制台] 的 [地區及語言選項] 部分變更貨幣設定,貨幣可能會不正確。Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. 若要使用 .NET Framework 的貨幣預設值,應用程式應該使用接受 useUserOverride 參數的 CultureInfo 函式多載,並將它設定為 falseTo use the .NET Framework default setting for the currency, the application should use a CultureInfo constructor overload that accepts a useUserOverride parameter and set it to false.

注意

針對回溯相容性,使用0x0004 或0x7c04 的 culture 參數所建立的文化特性,分別具有 zh-CHS 或 zh CHT 的 Name 屬性。For backwards compatibility, a culture constructed using a culture parameter of 0x0004 or 0x7c04 will have a Name property of zh-CHS or zh-CHT, respectively. 您應該改用 zh-Hans 或 zh 的目前標準文化特性名稱來建立文化特性,除非您有使用較舊名稱的原因。You should instead prefer to construct the culture using the current standard culture names of zh-Hans or zh-Hant, unless you have a reason for using the older names.

給呼叫者的注意事項

如果 culture 不是有效的文化特性識別碼,.NET Framework 3.5.NET Framework 3.5 和較早的版本會擲回 ArgumentExceptionThe .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. .NET Framework 4.NET Framework 4開始,此函式會擲回 CultureNotFoundExceptionStarting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 從在 Windows 7 或更新版本的 .NET Framework 4.NET Framework 4 或更新版本下執行的應用程式開始,方法會嘗試取出 CultureInfo 物件,其識別碼是從作業系統 culture 的,如果作業系統不支援該文化特性,方法會擲回 CultureNotFoundException 例外狀況。Starting with apps that run under the .NET Framework 4.NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is culture from the operating system; if the operating system does not support that culture, the method throws a CultureNotFoundException exception.

另請參閱

CultureInfo(String)

根據名稱所指定的文化特性,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by name.

public:
 CultureInfo(System::String ^ name);
public CultureInfo (string name);
new System.Globalization.CultureInfo : string -> System.Globalization.CultureInfo
Public Sub New (name As String)

參數

name
String

預先定義的 CultureInfo 名稱、現有 NameCultureInfo,或 Windows 專用文化特性名稱。A predefined CultureInfo name, Name of an existing CultureInfo, or Windows-only culture name. name 不區分大小寫。name is not case-sensitive.

例外狀況

name 為 null。name is null.

name 不是有效的文化特性名稱。name is not a valid culture name. 如需詳細資訊,請參閱<呼叫者注意事項>一節。For more information, see the Notes to Callers section.

範例

下列範例會抓取目前的文化特性。The following example retrieves the current culture. 如果它是法文(法國)文化特性以外的任何專案,它會呼叫 CultureInfo(String) 的函式來具現化代表法文(法國)文化特性的 CultureInfo 物件,並使其成為目前的執行緒文化特性。If it is anything other than the French (France) culture, it calls the CultureInfo(String) constructor to instantiate a CultureInfo object that represents the French (France) culture and makes it the current thread culture. 否則,它會具現化代表法文(盧森堡)文化特性的 CultureInfo 物件,並使其成為目前的文化特性。Otherwise, it instantiates a CultureInfo object that represents the French (Luxembourg) culture and makes it the current culture.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      CultureInfo current = CultureInfo.CurrentCulture;
      Console.WriteLine("The current culture is {0}", current.Name);
      CultureInfo newCulture;
      if (current.Name.Equals("fr-FR"))
         newCulture = new CultureInfo("fr-LU");
      else   
         newCulture = new CultureInfo("fr-FR");
      
      CultureInfo.CurrentCulture = newCulture;
      Console.WriteLine("The current culture is now {0}", 
                        CultureInfo.CurrentCulture.Name);   
   }
}
// The example displays output like the following:
//     The current culture is en-US
//     The current culture is now fr-FR
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim current As CultureInfo = CultureInfo.CurrentCulture
      Console.WriteLine("The current culture is {0}", current.Name)
      Dim newCulture As CultureInfo
      If current.Name.Equals("fr-FR") Then
         newCulture = New CultureInfo("fr-LU")
      Else   
         newCulture = new CultureInfo("fr-FR")
      End If
      
      CultureInfo.CurrentCulture = newCulture
      Console.WriteLine("The current culture is now {0}", 
                        CultureInfo.CurrentCulture.Name)   
   End Sub
End Module
' The example displays output like the following:
'     The current culture is en-US
'     The current culture is now fr-FR

備註

如需 Windows 系統上預先定義的文化特性名稱清單,請參閱windows 支援的語言/區功能變數名稱稱清單中的 [語言標記] 資料行。For a list of predefined culture names on Windows systems, see the Language tag column in the list of language/region names supported by Windows. 文化名稱遵循 BCP 47 定義的標準。Culture names follow the standard defined by BCP 47. 此外,從 Windows 10 開始,name 可以是任何有效的 BCP-47 語言標記。In addition, starting with Windows 10, name can be any valid BCP-47 language tag.

如果 String.Emptyname,則此函式會建立不因文化特性而異的實例;這相當於抓取 InvariantCulture 屬性的值。If name is String.Empty, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the InvariantCulture property.

使用者可以選擇透過 [控制台] 的 [地區及語言選項] 部分,覆寫與 Windows 目前文化特性相關聯的一些值。The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. 例如,使用者可能會選擇以不同的格式來顯示日期,或使用文化特性的預設值以外的貨幣。For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. 如果與 name 相關聯的文化特性識別碼符合目前 Windows 文化特性的文化特性識別碼,則此函式會建立使用這些覆寫的 CultureInfo 物件,包括 DateTimeFormat 屬性所傳回之 DateTimeFormatInfo 實例屬性的使用者設定,以及 NumberFormatInfo 屬性所傳回之 NumberFormat 實例的屬性。If the culture identifier associated with name matches the culture identifier of the current Windows culture, this constructor creates a CultureInfo object that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormat property, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. 如果使用者設定與 CultureInfo相關聯的文化特性不相容,例如,如果選取的行事曆不是其中一個 OptionalCalendars,則方法的結果和屬性的值會是未定義的。If the user settings are incompatible with the culture associated with the CultureInfo, for example, if the selected calendar is not one of the OptionalCalendars, the results of the methods and the values of the properties are undefined.

如果與 name 相關聯的文化特性識別碼不符合目前 Windows 文化特性的文化特性識別碼,則此函式會建立一個 CultureInfo 物件,它會針對指定的文化特性使用預設值。If the culture identifier associated with name does not match the culture identifier of the current Windows culture, this constructor creates a CultureInfo object that uses the default values for the specified culture.

UseUserOverride 屬性一律設為 trueThe UseUserOverride property is always set to true.

例如,假設阿拉伯文(沙烏地阿拉伯)是 Windows 的目前文化特性,而使用者將行事曆從回曆變更為西曆。For example, suppose that Arabic (Saudi Arabia) is the current culture of Windows and the user changed the calendar from Hijri to Gregorian.

CultureInfoLCID 屬性會設定為與指定名稱相關聯的文化特性識別碼。The LCID property of the new CultureInfo is set to the culture identifier associated with the specified name.

對於使用歐元的文化特性,.NET Framework 和 Windows XP 會將預設貨幣設定為歐元。For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro. 不過,舊版的 Windows 不會這麼做。However, older versions of Windows do not do this. 因此,如果舊版 Windows 的使用者未透過 [控制台] 的 [地區及語言選項] 部分變更貨幣設定,貨幣可能會不正確。Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. 若要使用 .NET Framework 的貨幣預設值,應用程式應該使用接受 useUserOverride 參數的 CultureInfo 函式多載,並將它設定為 falseTo use the .NET Framework default setting for the currency, the application should use a CultureInfo constructor overload that accepts a useUserOverride parameter and set it to false.

給呼叫者的注意事項

如果 name 不是有效的文化特性名稱,.NET Framework 3.5.NET Framework 3.5 和較早的版本會擲回 ArgumentExceptionThe .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. .NET Framework 4.NET Framework 4開始,此函式會擲回 CultureNotFoundExceptionStarting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 從在 Windows 7 或更新版本的 .NET Framework 4.NET Framework 4 或更新版本下執行的應用程式開始,方法會嘗試取出 CultureInfo 物件,其識別碼是從作業系統 name 的,如果作業系統不支援該文化特性,而且如果 name 不是增補或取代文化特性的名稱,此方法就會擲回 CultureNotFoundException 例外狀況。Starting with apps that run under the .NET Framework 4.NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception.

另請參閱

CultureInfo(Int32, Boolean)

根據文化特性識別項所指定的文化特性,並根據指定是否要使用系統中使用者選取的文化特性設定的布林值,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier and on the Boolean that specifies whether to use the user-selected culture settings from the system.

public:
 CultureInfo(int culture, bool useUserOverride);
public CultureInfo (int culture, bool useUserOverride);
new System.Globalization.CultureInfo : int * bool -> System.Globalization.CultureInfo
Public Sub New (culture As Integer, useUserOverride As Boolean)

參數

culture
Int32

預先定義的 CultureInfo 識別項、現有 LCID 物件的 CultureInfo 屬性,或 Windows 專用文化特性識別項。A predefined CultureInfo identifier, LCID property of an existing CultureInfo object, or Windows-only culture identifier.

useUserOverride
Boolean

代表使用使用者選取的文化特性設定 (true) 或預設文化特性設定 (false) 的布林值。A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

例外狀況

culture 小於零。culture is less than zero.

culture 不是有效的文化特性識別項。culture is not a valid culture identifier. 如需詳細資訊,請參閱<呼叫者注意事項>一節。See the Notes to Callers section for more information.

備註

Windows 系統上可用的預先定義文化特性識別碼會列在windows 支援的語言/區功能變數名稱稱清單中的 [語言標記] 欄中。Predefined culture identifiers available on Windows systems are listed in the Language tag column in the list of language/region names supported by Windows. 文化名稱遵循 BCP 47 定義的標準。Culture names follow the standard defined by BCP 47.

在大部分的情況下,culture 參數會對應至相對應的國家語言支援(NLS)地區設定識別碼。In most cases, the culture parameter is mapped to the corresponding National Language Support (NLS) locale identifier. culture 參數的值會變成新 CultureInfoLCID 屬性值。The value of the culture parameter becomes the value of the LCID property of the new CultureInfo.

我們建議您 CultureInfo.CultureInfo呼叫地區設定名稱的函式,因為地區設定名稱優於 Lcid。We recommend that you call the locale name constructor CultureInfo.CultureInfo, because locale names are preferable to LCIDs. 若為自訂地區設定,則需要地區設定名稱。For custom locales, a locale name is required.

使用者可以選擇透過 [控制台] 的 [地區及語言選項] 部分,覆寫與 Windows 目前文化特性相關聯的一些值。The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. 例如,使用者可能會選擇以不同的格式來顯示日期,或使用文化特性的預設值以外的貨幣。For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture.

應用程式通常不允許使用者覆寫。Applications should typically not disallow user overrides. 請注意,不允許覆寫本身不保證資料穩定性;請參閱不應將 blog 專案文化特性資料視為穩定的(不變的例外)Note that disallowing overrides does not itself guarantee data stability; see the blog entry Culture data shouldn't be considered stable (except for Invariant).

如果 UseUserOverride 屬性設定為 true 而且指定的文化特性識別碼符合目前 Windows 文化特性的識別碼,則此函式會建立使用這些覆寫的 CultureInfo,包括 DateTimeFormat 屬性所傳回之 DateTimeFormatInfo 實例屬性的使用者設定,以及 NumberFormatInfo 屬性所傳回之 NumberFormat 實例的屬性。If the UseUserOverride property is set to true and the specified culture identifier matches the identifier of the current Windows culture, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormat property, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. 如果使用者設定與 CultureInfo相關聯的文化特性不相容,例如,如果選取的行事曆不是其中一個 OptionalCalendars,則方法的結果和屬性的值會是未定義的。If the user settings are incompatible with the culture associated with the CultureInfo, for example, if the selected calendar is not one of the OptionalCalendars, the results of the methods and the values of the properties are undefined.

否則,此函式會建立一個 CultureInfo,以針對指定的文化特性使用預設值。Otherwise, this constructor creates a CultureInfo that uses the default values for the specified culture.

useUserOverride 參數的值會變成 UseUserOverride 屬性的值。The value of the useUserOverride parameter becomes the value of the UseUserOverride property.

例如,假設阿拉伯文(沙烏地阿拉伯)是 Windows 的目前文化特性,而使用者已將行事曆從回曆變更為西曆。For example, suppose that Arabic (Saudi Arabia) is the current culture of Windows and the user has changed the calendar from Hijri to Gregorian.

對於使用歐元的文化特性,.NET Framework 和 Windows XP 會將預設貨幣設定為歐元。For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro. 不過,舊版的 Windows 則不會。However, older versions of Windows do not. 因此,如果舊版 Windows 的使用者未透過 [控制台] 的 [地區及語言選項] 部分變更貨幣設定,貨幣可能會不正確。Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. 若要使用 .NET Framework 的貨幣預設值,應用程式應該將 useUserOverride 參數設定為 [false]。To use the .NET Framework default setting for the currency, the application should set the useUserOverride parameter to false.

注意

針對回溯相容性,使用0x0004 或0x7c04 的 culture 參數所建立的文化特性,分別具有 zh-CHS 或 zh CHT 的 Name 屬性。For backwards compatibility, a culture constructed using a culture parameter of 0x0004 or 0x7c04 will have a Name property of zh-CHS or zh-CHT, respectively. 您應該改用 zh-Hans 或 zh 的目前標準文化特性名稱來建立文化特性,除非您有使用較舊名稱的原因。You should instead prefer to construct the culture using the current standard culture names of zh-Hans or zh-Hant, unless you have a reason for using the older names.

給呼叫者的注意事項

如果 culture 不是有效的文化特性識別碼,.NET Framework 3.5.NET Framework 3.5 和較早的版本會擲回 ArgumentExceptionThe .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. .NET Framework 4.NET Framework 4開始,此函式會擲回 CultureNotFoundExceptionStarting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 從在 Windows 7 或更新版本的 .NET Framework 4.NET Framework 4 或更新版本下執行的應用程式開始,方法會嘗試取出 CultureInfo 物件,其識別碼是從作業系統 culture 的,如果作業系統不支援該文化特性,方法會擲回 CultureNotFoundException 例外狀況。Starting with apps that run under the .NET Framework 4.NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is culture from the operating system; if the operating system does not support that culture, the method throws a CultureNotFoundException exception.

另請參閱

CultureInfo(String, Boolean)

根據名稱所指定的文化特性,並根據指示是否要從系統中使用使用者選取的文化特性設定的布林值,初始化 CultureInfo 類別的新執行個體。Initializes a new instance of the CultureInfo class based on the culture specified by name and on the Boolean that specifies whether to use the user-selected culture settings from the system.

public:
 CultureInfo(System::String ^ name, bool useUserOverride);
public CultureInfo (string name, bool useUserOverride);
new System.Globalization.CultureInfo : string * bool -> System.Globalization.CultureInfo
Public Sub New (name As String, useUserOverride As Boolean)

參數

name
String

預先定義的 CultureInfo 名稱、現有 NameCultureInfo,或 Windows 專用文化特性名稱。A predefined CultureInfo name, Name of an existing CultureInfo, or Windows-only culture name. name 不區分大小寫。name is not case-sensitive.

useUserOverride
Boolean

代表使用使用者選取的文化特性設定 (true) 或預設文化特性設定 (false) 的布林值。A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

例外狀況

name 為 null。name is null.

name 不是有效的文化特性名稱。name is not a valid culture name. 如需詳細資訊,請參閱<呼叫者注意事項>一節。See the Notes to Callers section for more information.

備註

如需預先定義的文化特性名稱清單,請參閱Windows 支援的語言/區功能變數名稱稱清單中的 [語言標記] 資料行。For a list of predefined culture names, see the Language tag column in the list of language/region names supported by Windows. 文化名稱遵循 BCP 47 定義的標準。Culture names follow the standard defined by BCP 47. 此外,從 Windows 10 開始,name 可以是任何有效的 BCP-47 語言標記。In addition, starting with Windows 10, name can be any valid BCP-47 language tag.

如果 String.Emptyname,則此函式會建立不因文化特性而異的實例;這相當於抓取 InvariantCulture 屬性的值。If name is String.Empty, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the InvariantCulture property.

使用者可以選擇透過 [控制台] 的 [地區及語言選項] 部分,覆寫與目前 Windows 文化特性相關聯的一些值。The user might choose to override some of the values associated with the current Windows culture through the regional and language options portion of Control Panel. 例如,使用者可能會選擇以不同的格式來顯示日期,或使用文化特性的預設值以外的貨幣。For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture.

應用程式通常不允許使用者覆寫。Applications should typically not disallow user overrides. 請注意,不允許覆寫本身不保證資料穩定性;請參閱不應將 blog 專案文化特性資料視為穩定的(不變的例外)Note that disallowing overrides does not itself guarantee data stability; see the blog entry Culture data shouldn't be considered stable (except for Invariant).

如果 UseUserOverride 屬性設定為 true 而且與指定文化特性名稱相關聯的文化特性識別碼符合目前 Windows 文化特性的文化特性識別碼,則此函式會建立使用這些覆寫的 CultureInfo,包括 DateTimeFormat 屬性所傳回之 DateTimeFormatInfo 實例屬性的使用者設定,以及 NumberFormatInfo 屬性所傳回之 NumberFormat 實例的屬性。If the UseUserOverride property is set to true and the culture identifier associated with the specified culture name matches the culture identifier of the current Windows culture, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormat property, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. 如果使用者設定與 CultureInfo相關聯的文化特性不相容,例如,如果選取的行事曆不是其中一個 OptionalCalendars,則方法的結果和屬性的值會是未定義的。If the user settings are incompatible with the culture associated with the CultureInfo, for example, if the selected calendar is not one of the OptionalCalendars, the results of the methods and the values of the properties are undefined.

否則,此函式會建立一個 CultureInfo,以針對指定的文化特性使用預設值。Otherwise, this constructor creates a CultureInfo that uses the default values for the specified culture.

useUserOverride 參數的值會變成 UseUserOverride 屬性的值。The value of the useUserOverride parameter becomes the value of the UseUserOverride property.

例如,假設阿拉伯文(沙烏地阿拉伯)是 Windows 的目前文化特性,而使用者將行事曆從回曆變更為西曆。For example, suppose that Arabic (Saudi Arabia) is the current culture of Windows and the user changed the calendar from Hijri to Gregorian.

CultureInfoLCID 屬性會設定為與指定名稱相關聯的文化特性識別碼。The LCID property of the new CultureInfo is set to the culture identifier associated with the specified name.

對於使用歐元的文化特性,.NET Framework 和 Windows XP 會將預設貨幣設定為歐元。For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro. 不過,舊版的 Windows 不會這麼做。However, older versions of Windows do not do this. 因此,如果舊版 Windows 的使用者未透過 [控制台] 的 [地區及語言選項] 部分變更貨幣設定,貨幣可能會不正確。Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. 若要使用 .NET Framework 的貨幣預設值,應用程式應該將 useUserOverride 參數設定為 [false]。To use the .NET Framework default setting for the currency, the application should set the useUserOverride parameter to false.

給呼叫者的注意事項

如果 name 不是有效的文化特性名稱,.NET Framework 3.5.NET Framework 3.5 和較早的版本會擲回 ArgumentExceptionThe .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. .NET Framework 4.NET Framework 4開始,此函式會擲回 CultureNotFoundExceptionStarting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 從在 Windows 7 或更新版本的 .NET Framework 4.NET Framework 4 或更新版本下執行的應用程式開始,方法會嘗試取出 CultureInfo 物件,其識別碼是從作業系統 name 的,如果作業系統不支援該文化特性,而且如果 name 不是增補或取代文化特性的名稱,此方法就會擲回 CultureNotFoundException 例外狀況。Starting with apps that run under the .NET Framework 4.NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception.

另請參閱

適用於