CultureInfo CultureInfo CultureInfo CultureInfo Constructors

定义

重载

CultureInfo(Int32) CultureInfo(Int32) CultureInfo(Int32) CultureInfo(Int32)

根据区域性标识符指定的区域性初始化 CultureInfo 类的新实例。Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier.

CultureInfo(String) CultureInfo(String) CultureInfo(String) CultureInfo(String)

根据由名称指定的区域性初始化 CultureInfo 类的新实例。Initializes a new instance of the CultureInfo class based on the culture specified by name.

CultureInfo(Int32, Boolean) CultureInfo(Int32, Boolean) CultureInfo(Int32, Boolean) 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(String, Boolean) CultureInfo(String, Boolean) 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(Int32) CultureInfo(Int32) 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 Int32 Int32 Int32

预定义的 CultureInfo 标识符、现有 CultureInfo 对象的 LCID 属性或仅 Windows 区域性标识符。A predefined CultureInfo identifier, LCID property of an existing CultureInfo object, or Windows-only culture identifier.

异常

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.

建议调用 locale 名称构造函数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一个使用这些重写的,包括由DateTimeFormatInfo属性和NumberFormatInfoNumberFormat属性返回的实例的属性。 DateTimeFormatIf 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 区域性的标识符不匹配,此构造函数将创建一个CultureInfo ,它使用指定区域性的默认值。If 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.

属性始终设置为trueUseUserOverrideThe 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 默认设置,应用程序应使用CultureInfo useUserOverride接受参数的构造函数重载,并将其设置为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.

备注

为了向后兼容,使用culture 0x0004 或0x7c04 的参数构造的区域性将分别Name具有 zh-chs-CHS 或 zh-chs-CHT 属性。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-chs-Hans 或 zh-chs-Zh-hant 的当前标准区域性名称构造区域性,除非你有使用旧名称的原因。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.

调用方说明

ArgumentException .NET Framework 3.5.NET Framework 3.5 如果culture不是有效的区域性标识符,则和更早的版本将引发。The .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. 从开始CultureNotFoundException,此构造函数引发。 .NET Framework 4.NET Framework 4Starting 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(String) CultureInfo(String) 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 String String String

预定义的 CultureInfo 名称、现有 CultureInfoName 或仅 Windows 区域性名称。A predefined CultureInfo name, Name of an existing CultureInfo, or Windows-only culture name. name 不区分大小写。name is not case-sensitive.

异常

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.

如果name InvariantCultureString.Empty,则构造函数将创建一个固定区域性的实例; 这等效于检索属性的值。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将创建一个使用这些重写的对象,包括的DateTimeFormatInfo属性的用户设置 NumberFormatDateTimeFormat属性返回的实例,以及由属性返回的NumberFormatInfo实例的属性。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.

属性始终设置为trueUseUserOverrideThe 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.

LCIDCultureInfo的的属性设置为与指定名称关联的区域性标识符。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 默认设置,应用程序应使用CultureInfo useUserOverride接受参数的构造函数重载,并将其设置为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.

调用方说明

ArgumentException .NET Framework 3.5.NET Framework 3.5 如果name不是有效的区域性名称,和更早的版本将引发。The .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. 从开始CultureNotFoundException,此构造函数引发。 .NET Framework 4.NET Framework 4Starting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 从在 Windows 7 或更高.NET Framework 4.NET Framework 4版本下的或更高版本下运行的应用程序,该CultureInfo方法会尝试检索name其标识符来自操作系统的对象; 如果操作系统不支持该区域性,则为; 如果不是补充或替代区域性的名称,该方法将CultureNotFoundException引发异常。 nameStarting 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(Int32, Boolean) CultureInfo(Int32, Boolean) 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 Int32 Int32 Int32

预定义的 CultureInfo 标识符、现有 CultureInfo 对象的 LCID 属性或仅 Windows 区域性标识符。A predefined CultureInfo identifier, LCID property of an existing CultureInfo object, or Windows-only culture identifier.

useUserOverride
Boolean Boolean Boolean 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 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.

建议调用 locale 名称构造函数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. 请注意,禁止替代本身并不保证数据稳定性;请参阅不应将博客条目区域性数据视为稳定的(固定的除外)Note that disallowing overrides does not itself guarantee data stability; see the blog entry Culture data shouldn't be considered stable (except for Invariant).

如果将true属性设置为,并且指定的区域性标识符与当前 Windows 区域性的标识符匹配,则此构造函数将CultureInfo创建一个使用这些重写的,其中包括属性的用户设置UseUserOverride由属性返回NumberFormatNumberFormatInfo实例的,以及由属性返回的实例的属性。 DateTimeFormatInfo DateTimeFormatIf 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参数设置为。 falseTo use the .NET Framework default setting for the currency, the application should set the useUserOverride parameter to false.

备注

为了向后兼容,使用culture 0x0004 或0x7c04 的参数构造的区域性将分别Name具有 zh-chs-CHS 或 zh-chs-CHT 属性。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-chs-Hans 或 zh-chs-Zh-hant 的当前标准区域性名称构造区域性,除非你有使用旧名称的原因。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.

调用方说明

ArgumentException .NET Framework 3.5.NET Framework 3.5 如果culture不是有效的区域性标识符,则和更早的版本将引发。The .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. 从开始CultureNotFoundException,此构造函数引发。 .NET Framework 4.NET Framework 4Starting 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(String, Boolean) CultureInfo(String, Boolean) 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 String String String

预定义的 CultureInfo 名称、现有 CultureInfoName 或仅 Windows 区域性名称。A predefined CultureInfo name, Name of an existing CultureInfo, or Windows-only culture name. name 不区分大小写。name is not case-sensitive.

useUserOverride
Boolean Boolean Boolean Boolean

一个布尔值,它指示是使用用户选定的区域性设置 (true),还是使用默认区域性设置 (false)。A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

异常

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.

如果name InvariantCultureString.Empty,则构造函数将创建一个固定区域性的实例; 这等效于检索属性的值。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. 请注意,禁止替代本身并不保证数据稳定性;请参阅不应将博客条目区域性数据视为稳定的(固定的除外)Note that disallowing overrides does not itself guarantee data stability; see the blog entry Culture data shouldn't be considered stable (except for Invariant).

如果将true属性设置为,并且与指定的区域性名称关联的区域性标识符与当前 Windows 区域性的区域性标识符相匹配,则此构造函数CultureInfo将创建一个使用这些替代的, UseUserOverride包含DateTimeFormatInfo NumberFormatInfo由属性返回的实例的属性的用户设置,以及由NumberFormat属性返回的实例的属性。 DateTimeFormatIf 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.

LCIDCultureInfo的的属性设置为与指定名称关联的区域性标识符。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参数设置为。 falseTo use the .NET Framework default setting for the currency, the application should set the useUserOverride parameter to false.

调用方说明

ArgumentException .NET Framework 3.5.NET Framework 3.5 如果name不是有效的区域性名称,和更早的版本将引发。The .NET Framework 3.5.NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. 从开始CultureNotFoundException,此构造函数引发。 .NET Framework 4.NET Framework 4Starting with the .NET Framework 4.NET Framework 4, this constructor throws a CultureNotFoundException. 从在 Windows 7 或更高.NET Framework 4.NET Framework 4版本下的或更高版本下运行的应用程序,该CultureInfo方法会尝试检索name其标识符来自操作系统的对象; 如果操作系统不支持该区域性,则为; 如果不是补充或替代区域性的名称,该方法将CultureNotFoundException引发异常。 nameStarting 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.

另请参阅

适用于