CultureAndRegionInfoBuilder(String, CultureAndRegionModifiers) 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 CultureAndRegionInfoBuilder 类的新实例。
public:
CultureAndRegionInfoBuilder(System::String ^ cultureName, System::Globalization::CultureAndRegionModifiers flags);
public CultureAndRegionInfoBuilder (string cultureName, System.Globalization.CultureAndRegionModifiers flags);
new System.Globalization.CultureAndRegionInfoBuilder : string * System.Globalization.CultureAndRegionModifiers -> System.Globalization.CultureAndRegionInfoBuilder
Public Sub New (cultureName As String, flags As CultureAndRegionModifiers)
参数
- cultureName
- String
区域性的名称。
一个 CultureAndRegionModifiers 值,指定新的 CultureAndRegionInfoBuilder 对象是非特定区域性、新区域性,还是要替换现有的区域性和国家/地区。
例外
cultureName
为 null
。
cultureName
为空字符串 ("")。
- 或 -
cultureName
包含除“0”到“9”、“a”到“z”、“A”到“Z”、连字符 (-) 或下划线 (_) 以外的字符。
- 或 -
cultureName
包含用于分隔各个部分的连字符 (-),但是缺少 prefix
、language
、region
或 suffix
这些部分中的一个或多个。 即,两个或更多的连字符是相邻的。
- 或 -
cultureName
的长度超过 84 个字符。
- 或 -
cultureName
包含用于分隔各个部分的连字符,但是有一个或多个部分的长度超过 8 个字符。
- 或 -
cultureName
包含前导或末尾连字符 (-) 或下划线 (_)。
- 或 -
cultureName
指定其他排序替换区域性而不是 .NET Framework 区域性。 例如,culturenName
是“de-de_phoneb”(按照德语电话簿中的显示顺序对字符串排序的区域性)而不是德语(德国)区域性“de-DE”。
- 或 -
flags
包含无效的 CultureAndRegionModifiers 值组合。
- 或 -
flags
包含 Replacement 或 Neutral,而且没有找到 cultureName
指定的区域性。
- 或 -
flags
包含 Replacement,而 cultureName
指定的由用户创建的自定义区域性没有替换 .NET Framework 附带的区域性。
- 或 -
flags
包含 Neutral,而 cultureName
指定的区域性不是非特定区域性。
- 或 -
flags
包含 Neutral,而 cultureName
指定的由用户创建的自定义区域性替换了 .NET Framework 附带的特定区域性。
示例
下面的代码示例创建一个带有专用前缀的自定义区域性,然后列出其一组属性。 第一个属性列出区域性的名称。
// This example demonstrates a System.Globalization.Culture-
// AndRegionInfoBuilder constructor and some of the properties
// of a custom culture object created with the constructor.
#using <sysglobl.dll>
using namespace System;
using namespace System::Globalization;
int main()
{
CultureAndRegionInfoBuilder^ builder =
gcnew CultureAndRegionInfoBuilder
("x-en-US-sample", CultureAndRegionModifiers::None);
// Display some of the properties
// for the en-US culture.
Console::WriteLine("CultureName:. . . . . . . . . . {0}",
builder->CultureName);
Console::WriteLine("CultureEnglishName: . . . . . . {0}",
builder->CultureEnglishName);
Console::WriteLine("CultureNativeName:. . . . . . . {0}",
builder->CultureNativeName);
Console::WriteLine("GeoId:. . . . . . . . . . . . . {0}",
builder->GeoId);
Console::WriteLine("IsMetric: . . . . . . . . . . . {0}",
builder->IsMetric);
Console::WriteLine("ISOCurrencySymbol:. . . . . . . {0}",
builder->ISOCurrencySymbol);
Console::WriteLine("RegionEnglishName:. . . . . . . {0}",
builder->RegionEnglishName);
Console::WriteLine("RegionName: . . . . . . . . . . {0}",
builder->RegionName);
Console::WriteLine("RegionNativeName: . . . . . . . {0}",
builder->RegionNativeName);
Console::WriteLine("ThreeLetterISOLanguageName: . . {0}",
builder->ThreeLetterISOLanguageName);
Console::WriteLine("ThreeLetterISORegionName: . . . {0}",
builder->ThreeLetterISORegionName);
Console::WriteLine("ThreeLetterWindowsLanguageName: {0}",
builder->ThreeLetterWindowsLanguageName);
Console::WriteLine("ThreeLetterWindowsRegionName: . {0}",
builder->ThreeLetterWindowsRegionName);
Console::WriteLine("TwoLetterISOLanguageName: . . . {0}",
builder->TwoLetterISOLanguageName);
Console::WriteLine("TwoLetterISORegionName: . . . . {0}",
builder->TwoLetterISORegionName);
}
/*
This code example produces the following results:
CultureName:. . . . . . . . . . en-US
CultureEnglishName: . . . . . . English (United States)
CultureNativeName:. . . . . . . English (United States)
GeoId:. . . . . . . . . . . . . 244
IsMetric: . . . . . . . . . . . False
ISOCurrencySymbol:. . . . . . . USD
RegionEnglishName:. . . . . . . United States
RegionName: . . . . . . . . . . US
RegionNativeName: . . . . . . . United States
ThreeLetterISOLanguageName: . . eng
ThreeLetterISORegionName: . . . USA
ThreeLetterWindowsLanguageName: ENU
ThreeLetterWindowsRegionName: . USA
TwoLetterISOLanguageName: . . . en
TwoLetterISORegionName: . . . . US
*/
// This example demonstrates a System.Globalization.Culture-
// AndRegionInfoBuilder constructor and some of the properties
// of the CultureAndRegionInfoBuilder object that is created.
// Compile this example with a reference to sysglobl.dll.
using System;
using System.Globalization;
class Sample
{
public static void Main()
{
// Construct a new, privately used culture that extends the en-US culture
// provided by the .NET Framework. In this sample, the CultureAndRegion-
// Types.Specific parameter creates a minimal CultureAndRegionInfoBuilder
// object that you must populate with culture and region information.
CultureAndRegionInfoBuilder cib = null;
try {
cib = new CultureAndRegionInfoBuilder(
"x-en-US-sample",
CultureAndRegionModifiers.None);
}
catch (ArgumentException ae)
{
Console.WriteLine(ae);
return;
}
// Populate the new CultureAndRegionInfoBuilder object with culture information.
CultureInfo ci = new CultureInfo("en-US");
cib.LoadDataFromCultureInfo(ci);
// Populate the new CultureAndRegionInfoBuilder object with region information.
RegionInfo ri = new RegionInfo("US");
cib.LoadDataFromRegionInfo(ri);
// Display some of the properties for the x-en-US-sample custom culture.
Console.Clear();
Console.WriteLine("CultureName:. . . . . . . . . . {0}", cib.CultureName);
Console.WriteLine("CultureEnglishName: . . . . . . {0}", cib.CultureEnglishName);
Console.WriteLine("CultureNativeName:. . . . . . . {0}", cib.CultureNativeName);
Console.WriteLine("GeoId:. . . . . . . . . . . . . {0}", cib.GeoId);
Console.WriteLine("IsMetric: . . . . . . . . . . . {0}", cib.IsMetric);
Console.WriteLine("ISOCurrencySymbol:. . . . . . . {0}", cib.ISOCurrencySymbol);
Console.WriteLine("RegionEnglishName:. . . . . . . {0}", cib.RegionEnglishName);
Console.WriteLine("RegionName: . . . . . . . . . . {0}", cib.RegionName);
Console.WriteLine("RegionNativeName: . . . . . . . {0}", cib.RegionNativeName);
Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", cib.ThreeLetterISOLanguageName);
Console.WriteLine("ThreeLetterISORegionName: . . . {0}", cib.ThreeLetterISORegionName);
Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", cib.ThreeLetterWindowsLanguageName);
Console.WriteLine("ThreeLetterWindowsRegionName: . {0}", cib.ThreeLetterWindowsRegionName);
Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", cib.TwoLetterISOLanguageName);
Console.WriteLine("TwoLetterISORegionName: . . . . {0}", cib.TwoLetterISORegionName);
}
}
/*
This code example produces the following results:
CultureName:. . . . . . . . . . x-en-US-sample
CultureEnglishName: . . . . . . English
CultureNativeName:. . . . . . . English
GeoId:. . . . . . . . . . . . . 244
IsMetric: . . . . . . . . . . . False
ISOCurrencySymbol:. . . . . . . USD
RegionEnglishName:. . . . . . . United States
RegionName: . . . . . . . . . . US
RegionNativeName: . . . . . . . United States
ThreeLetterISOLanguageName: . . eng
ThreeLetterISORegionName: . . . USA
ThreeLetterWindowsLanguageName: ENU
ThreeLetterWindowsRegionName: . USA
TwoLetterISOLanguageName: . . . en
TwoLetterISORegionName: . . . . US
*/
' This example demonstrates a System.Globalization.Culture-
' AndRegionInfoBuilder constructor and some of the properties
' of the CultureAndRegionInfoBuilder object that is created.
' Compile this example with a reference to sysglobl.dll.
Imports System.Globalization
Class Sample
Public Shared Sub Main()
' Construct a new, privately used culture that extends the en-US culture
' provided by the .NET Framework. In this sample, the CultureAndRegion-
' Types.Specific parameter creates a minimal CultureAndRegionInfoBuilder
' object that you must populate with culture and region information.
Dim cib As CultureAndRegionInfoBuilder = Nothing
Try
cib = New CultureAndRegionInfoBuilder("x-en-US-sample", _
CultureAndRegionModifiers.None)
Catch ae As ArgumentException
Console.WriteLine(ae)
Return
End Try
' Populate the new CultureAndRegionInfoBuilder object with culture information.
Dim ci As New CultureInfo("en-US")
cib.LoadDataFromCultureInfo(ci)
' Populate the new CultureAndRegionInfoBuilder object with region information.
Dim ri As New RegionInfo("US")
cib.LoadDataFromRegionInfo(ri)
' Display some of the properties for the x-en-US-sample custom culture.
Console.Clear()
Console.WriteLine("CultureName:. . . . . . . . . . {0}", cib.CultureName)
Console.WriteLine("CultureEnglishName: . . . . . . {0}", cib.CultureEnglishName)
Console.WriteLine("CultureNativeName:. . . . . . . {0}", cib.CultureNativeName)
Console.WriteLine("GeoId:. . . . . . . . . . . . . {0}", cib.GeoId)
Console.WriteLine("IsMetric: . . . . . . . . . . . {0}", cib.IsMetric)
Console.WriteLine("ISOCurrencySymbol:. . . . . . . {0}", cib.ISOCurrencySymbol)
Console.WriteLine("RegionEnglishName:. . . . . . . {0}", cib.RegionEnglishName)
Console.WriteLine("RegionName: . . . . . . . . . . {0}", cib.RegionName)
Console.WriteLine("RegionNativeName: . . . . . . . {0}", cib.RegionNativeName)
Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", cib.ThreeLetterISOLanguageName)
Console.WriteLine("ThreeLetterISORegionName: . . . {0}", cib.ThreeLetterISORegionName)
Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", cib.ThreeLetterWindowsLanguageName)
Console.WriteLine("ThreeLetterWindowsRegionName: . {0}", cib.ThreeLetterWindowsRegionName)
Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", cib.TwoLetterISOLanguageName)
Console.WriteLine("TwoLetterISORegionName: . . . . {0}", cib.TwoLetterISORegionName)
End Sub
End Class
'
'This code example produces the following results:
'
'CultureName:. . . . . . . . . . x-en-US-sample
'CultureEnglishName: . . . . . . English
'CultureNativeName:. . . . . . . English
'GeoId:. . . . . . . . . . . . . 244
'IsMetric: . . . . . . . . . . . False
'ISOCurrencySymbol:. . . . . . . USD
'RegionEnglishName:. . . . . . . United States
'RegionName: . . . . . . . . . . US
'RegionNativeName: . . . . . . . United States
'ThreeLetterISOLanguageName: . . eng
'ThreeLetterISORegionName: . . . USA
'ThreeLetterWindowsLanguageName: ENU
'ThreeLetterWindowsRegionName: . USA
'TwoLetterISOLanguageName: . . . en
'TwoLetterISORegionName: . . . . US
'
注解
有关此 API 的详细信息,请参阅 System.Globalization.CultureAndRegionInfoBuilder 构造函数的补充 API 备注。