Export (0) Print
Expand All

CultureInfo.CreateSpecificCulture Method

Creates a CultureInfo object that represents the specific culture that is associated with the specified name.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public static CultureInfo CreateSpecificCulture(
	string name
)

Parameters

name
Type: System.String

A predefined CultureInfo name or the name of an existing CultureInfo object.

Return Value

Type: System.Globalization.CultureInfo
A CultureInfo object that represents:
The invariant culture, if name is an empty string ("").
-or-
The specific culture associated with name, if name is a neutral culture.
-or-
The culture specified by name, if name is already a specific culture.

ExceptionCondition
ArgumentException

name is not a valid culture name.

-or-

The culture specified by name does not have a specific culture associated with it.

NullReferenceException

name is null.

For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center.

Cultures are grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures. For more information, see the description of the CultureInfo class.

If the culture identifier associated with the specified culture name matches the culture identifier of the current Windows culture, this method creates a CultureInfo object that uses the Windows culture overrides. The overrides include user settings for the properties of the DateTimeFormatInfo object returned by the DateTimeFormat property, and the properties of the NumberFormatInfo object returned by the NumberFormat property.

The following code example shows the results of CreateSpecificCulture with different culture types.

NoteNote:

The example displays the zh-CHS and zh-CHT cultures with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the zh-Hans name instead of "zh-CHS" and the zh-Hant name instead of "zh-CHT". The zh-Hans and zh-Hant names represent the current standard, and should be used unless you have a reason for using the older names.

using System;
using System.Globalization;

public class SamplesCultureInfo  {

   public static void Main()  {

      // Prints the header.
      Console.WriteLine( "CULTURE                                              SPECIFIC CULTURE" );

      // Determines the specific culture associated with each culture in the .NET Framework. 
      foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.AllCultures ) )  {
         Console.Write( "{0,-12} {1,-40}", ci.Name, ci.EnglishName );
         try  {
            Console.WriteLine( "{0}", CultureInfo.CreateSpecificCulture( ci.Name ).Name );
         }
         catch  {
            Console.WriteLine( "(no associated specific culture)" );
         }
      }

   }

}


/*
This code produces the following output.  This output has been cropped for brevity.

CULTURE                                              SPECIFIC CULTURE
ar           Arabic                                  ar-SA
bg           Bulgarian                               bg-BG
ca           Catalan                                 ca-ES
zh-CHS       Chinese (Simplified)                    (no associated specific culture)
cs           Czech                                   cs-CZ
da           Danish                                  da-DK
de           German                                  de-DE
el           Greek                                   el-GR
en           English                                 en-US
es           Spanish                                 es-ES
fi           Finnish                                 fi-FI
fr           French                                  fr-FR
he           Hebrew                                  he-IL
hu           Hungarian                               hu-HU
is           Icelandic                               is-IS
it           Italian                                 it-IT
ja           Japanese                                ja-JP
ko           Korean                                  ko-KR
nl           Dutch                                   nl-NL
no           Norwegian                               nb-NO
pl           Polish                                  pl-PL
pt           Portuguese                              pt-BR
ro           Romanian                                ro-RO
ru           Russian                                 ru-RU
hr           Croatian                                hr-HR
sk           Slovak                                  sk-SK
sq           Albanian                                sq-AL
sv           Swedish                                 sv-SE
th           Thai                                    th-TH
tr           Turkish                                 tr-TR
ur           Urdu                                    ur-PK
id           Indonesian                              id-ID
uk           Ukrainian                               uk-UA
be           Belarusian                              be-BY
sl           Slovenian                               sl-SI
et           Estonian                                et-EE
lv           Latvian                                 lv-LV
lt           Lithuanian                              lt-LT
fa           Persian                                 fa-IR
vi           Vietnamese                              vi-VN
hy           Armenian                                hy-AM
az           Azeri                                   az-Latn-AZ

*/

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft