CultureInfo.GetCultures 方法
获取由指定 CultureTypes 参数筛选的支持的区域性列表。
**命名空间:**System.Globalization
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public Shared Function GetCultures ( _
types As CultureTypes _
) As CultureInfo()
用法
Dim types As CultureTypes
Dim returnValue As CultureInfo()
returnValue = CultureInfo.GetCultures(types)
public static CultureInfo[] GetCultures (
CultureTypes types
)
public:
static array<CultureInfo^>^ GetCultures (
CultureTypes types
)
public static CultureInfo[] GetCultures (
CultureTypes types
)
public static function GetCultures (
types : CultureTypes
) : CultureInfo[]
参数
- types
按位组合的 CultureTypes 值,用于筛选要检索的区域性。
返回值
包含由 types 参数指定的区域性的 CultureInfo 类型的数组。区域性数组未排序。
异常
异常类型 | 条件 |
---|---|
types 指定了无效的 CultureTypes 值组合。 |
备注
将 types 参数设置为 SpecificCultures 值将返回所有特定的区域性。将 types 设置为 NeutralCultures 值将返回所有非特定区域性和固定区域性。将 types 设置为 AllCultures 值将返回所有非特定区域性和特定区域性、安装在 Windows 系统中的区域性以及用户创建的自定义区域性。
示例
下面的代码示例显示了非特定区域性的几个属性。
Imports System
Imports System.Globalization
Public Class SamplesCultureInfo
Public Shared Sub Main()
' Displays several properties of the neutral cultures.
Console.WriteLine("CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME")
Dim ci As CultureInfo
For Each ci In CultureInfo.GetCultures(CultureTypes.NeutralCultures)
Console.Write("{0,-7}", ci.Name)
Console.Write(" {0,-3}", ci.TwoLetterISOLanguageName)
Console.Write(" {0,-3}", ci.ThreeLetterISOLanguageName)
Console.Write(" {0,-3}", ci.ThreeLetterWindowsLanguageName)
Console.Write(" {0,-40}", ci.DisplayName)
Console.WriteLine(" {0,-40}", ci.EnglishName)
Next ci
End Sub 'Main
End Class 'SamplesCultureInfo
'This code produces the following output. This output has been cropped for brevity.
'
'CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
'ar ar ara ARA Arabic Arabic
'bg bg bul BGR Bulgarian Bulgarian
'ca ca cat CAT Catalan Catalan
'zh-CHS zh zho CHS Chinese (Simplified) Chinese (Simplified)
'zh-CHT zh zho CHT Chinese (Traditional) Chinese (Traditional)
'cs cs ces CSY Czech Czech
'da da dan DAN Danish Danish
'de de deu DEU German German
'el el ell ELL Greek Greek
'en en eng ENU English English
'es es spa ESP Spanish Spanish
'fi fi fin FIN Finnish Finnish
using System;
using System.Globalization;
public class SamplesCultureInfo {
public static void Main() {
// Displays several properties of the neutral cultures.
Console.WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME" );
foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.NeutralCultures ) ) {
Console.Write( "{0,-7}", ci.Name );
Console.Write( " {0,-3}", ci.TwoLetterISOLanguageName );
Console.Write( " {0,-3}", ci.ThreeLetterISOLanguageName );
Console.Write( " {0,-3}", ci.ThreeLetterWindowsLanguageName );
Console.Write( " {0,-40}", ci.DisplayName );
Console.WriteLine( " {0,-40}", ci.EnglishName );
}
}
}
/*
This code produces the following output. This output has been cropped for brevity.
CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
ar ar ara ARA Arabic Arabic
bg bg bul BGR Bulgarian Bulgarian
ca ca cat CAT Catalan Catalan
zh-CHS zh zho CHS Chinese (Simplified) Chinese (Simplified)
zh-CHT zh zho CHT Chinese (Traditional) Chinese (Traditional)
cs cs ces CSY Czech Czech
da da dan DAN Danish Danish
de de deu DEU German German
el el ell ELL Greek Greek
en en eng ENU English English
es es spa ESP Spanish Spanish
fi fi fin FIN Finnish Finnish
*/
using namespace System;
using namespace System::Globalization;
int main()
{
// Displays several properties of the neutral cultures.
Console::WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME" );
System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::NeutralCultures )->GetEnumerator();
while ( enum0->MoveNext() )
{
CultureInfo^ ci = safe_cast<CultureInfo^>(enum0->Current);
Console::Write( "{0,-7}", ci->Name );
Console::Write( " {0,-3}", ci->TwoLetterISOLanguageName );
Console::Write( " {0,-3}", ci->ThreeLetterISOLanguageName );
Console::Write( " {0,-3}", ci->ThreeLetterWindowsLanguageName );
Console::Write( " {0,-40}", ci->DisplayName );
Console::WriteLine( " {0,-40}", ci->EnglishName );
}
}
/*
This code produces the following output. This output has been cropped for brevity.
CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
ar ar ara ARA Arabic Arabic
bg bg bul BGR Bulgarian Bulgarian
ca ca cat CAT Catalan Catalan
zh-CHS zh zho CHS Chinese (Simplified) Chinese (Simplified)
zh-CHT zh zho CHT Chinese (Traditional) Chinese (Traditional)
cs cs ces CSY Czech Czech
da da dan DAN Danish Danish
de de deu DEU German German
el el ell ELL Greek Greek
en en eng ENU English English
es es spa ESP Spanish Spanish
fi fi fin FIN Finnish Finnish
*/
import System.* ;
import System.Globalization.* ;
public class SamplesCultureInfo
{
public static void main(String[] args)
{
// Displays several properties of the neutral cultures.
Console.WriteLine("CULTURE ISO ISO WIN DISPLAYNAME "
+ " ENGLISHNAME");
for (int iCtr = 0;
iCtr < (CultureInfo.GetCultures(CultureTypes.NeutralCultures).
length); iCtr++) {
CultureInfo ci =
CultureInfo.GetCultures(CultureTypes.NeutralCultures)[iCtr];
Console.Write("{0,-7}", ci.get_Name());
Console.Write(" {0,-3}", ci.get_TwoLetterISOLanguageName());
Console.Write(" {0,-3}", ci.get_ThreeLetterISOLanguageName());
Console.Write(" {0,-3}", ci.get_ThreeLetterWindowsLanguageName());
Console.Write(" {0,-40}", ci.get_DisplayName());
Console.WriteLine(" {0,-40}", ci.get_EnglishName());
}
} //main
} //SamplesCultureInfo
/*
This code produces the following output. This output has been cropped
for brevity.
CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
ar ar ara ARA Arabic Arabic
bg bg bul BGR Bulgarian Bulgarian
ca ca cat CAT Catalan Catalan
zh-CHS zh zho CHS Chinese (Simplified) Chinese
(Simplified)
zh-CHT zh zho CHT Chinese (Traditional) Chinese
(Traditional)
cs cs ces CSY Czech Czech
da da dan DAN Danish Danish
de de deu DEU German German
el el ell ELL Greek Greek
en en eng ENU English English
es es spa ESP Spanish Spanish
fi fi fin FIN Finnish Finnish
*/
平台
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
CultureInfo 类
CultureInfo 成员
System.Globalization 命名空间
CultureTypes