CultureAndRegionModifiers 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定定义 CultureAndRegionInfoBuilder 对象的常数。
此枚举支持其成员值的按位组合。
public enum class CultureAndRegionModifiers
[System.Flags]
public enum CultureAndRegionModifiers
[<System.Flags>]
type CultureAndRegionModifiers =
Public Enum CultureAndRegionModifiers
- 继承
- 属性
字段
Neutral | 1 | 一个非特定的自定义区域性。 |
None | 0 | 一个特定的附加自定义区域性。 |
Replacement | 2 | 一个替换现有 .NET 区域性或 Windows 区域设置的自定义区域性。 |
示例
下面的代码示例创建一个带有专用前缀的自定义区域性,然后列出其一组属性。 第一个属性是区域性的名称。
// 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
'
注解
指定一个或多个 CultureAndRegionModifiers 值的按位组合作为构造函数的参数 CultureAndRegionInfoBuilder.CultureAndRegionInfoBuilder(String, CultureAndRegionModifiers) 。 使用生成的 CultureAndRegionInfoBuilder 对象创建自定义区域性。
自定义区域性可以具有以下特征的组合:
自定义区域性可以是特定区域性或非特定区域性。
特定区域性指定语言和区域,而非特定区域性指定语言但不指定区域。
自定义区域性可以是替换区域性或补充区域性。
替换区域性替换随.NET Framework附带的区域性或 Windows 附带的区域设置。
补充区域性是替代区域性以外的任何内容。 补充区域性可以是全新的,也可以扩展现有的.NET Framework区域性或 Windows 区域设置。
重要
请注意, CultureAndRegionModifiers 枚举位于名为 sysglobl.dll 的程序集中。 若要成功编译使用此类型的代码,需要添加对 sysglobl.dll 的引用。