Export (0) Print
Expand All
1 out of 5 rated this helpful - Rate this topic

CultureInfo.CreateSpecificCulture Method

Creates a CultureInfo 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
)
public static CultureInfo CreateSpecificCulture (
	String name
)
public static function CreateSpecificCulture (
	name : String
) : CultureInfo

Parameters

name

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

Return Value

A CultureInfo 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.
Exception typeCondition

ArgumentNullException

name is a null reference (Nothing in Visual Basic).

ArgumentException

name is not a valid culture name.

-or-

The culture specified by name does not have a specific culture associated with it. For example: "zh-CHS" or "zh-CHT".

The cultures are generally grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures.

The invariant culture is culture-insensitive. You can specify the invariant culture by name using an empty string ("") or by its culture identifier 0x007F. InvariantCulture retrieves an instance of the invariant culture. It is associated with the English language but not with any country/region. It can be used in almost any method in the Globalization namespace that requires a culture.

A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, "fr" is a neutral culture and "fr-FR" is a specific culture. Note that "zh-CHS" (Simplified Chinese) and "zh-CHT" (Traditional Chinese) are neutral cultures.

The cultures have a hierarchy, such that the parent of a specific culture is a neutral culture and the parent of a neutral culture is the InvariantCulture. The Parent property returns the neutral culture associated with a specific culture.

If the resources for the specific culture are not available in the system, the resources for the neutral culture are used; if the resources for the neutral culture are not available, the resources embedded in the main assembly are used. For more information on the resource fallback process, see Packaging and Deploying Resources.

The list of cultures in the Windows API is slightly different from the list of cultures in the .NET Framework. For example, the neutral culture zh-CHT "Chinese (Traditional)" with culture identifier 0x7C04 is not available in the Windows API. If interoperability with Windows is required (for example, through the p/invoke mechanism), use a specific culture that is defined in the operating system. This will ensure consistency with the equivalent Windows locale, which is identified with the same LCID.

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

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
ar-SA        Arabic (Saudi Arabia)                   ar-SA
ar-IQ        Arabic (Iraq)                           ar-IQ
ar-EG        Arabic (Egypt)                          ar-EG
ar-LY        Arabic (Libya)                          ar-LY
ar-DZ        Arabic (Algeria)                        ar-DZ
ar-MA        Arabic (Morocco)                        ar-MA
ar-TN        Arabic (Tunisia)                        ar-TN
ar-OM        Arabic (Oman)                           ar-OM
ar-YE        Arabic (Yemen)                          ar-YE
ar-SY        Arabic (Syria)                          ar-SY
ar-JO        Arabic (Jordan)                         ar-JO
ar-LB        Arabic (Lebanon)                        ar-LB
ar-KW        Arabic (Kuwait)                         ar-KW
ar-AE        Arabic (U.A.E.)                         ar-AE
ar-BH        Arabic (Bahrain)                        ar-BH
ar-QA        Arabic (Qatar)                          ar-QA
bg           Bulgarian                               bg-BG
bg-BG        Bulgarian (Bulgaria)                    bg-BG
ca           Catalan                                 ca-ES
ca-ES        Catalan (Catalan)                       ca-ES
zh-CHS       Chinese (Simplified)                    (no associated specific culture)
zh-TW        Chinese (Taiwan)                        zh-TW
zh-CN        Chinese (People's Republic of China)    zh-CN
zh-HK        Chinese (Hong Kong S.A.R.)              zh-HK
zh-SG        Chinese (Singapore)                     zh-SG
zh-MO        Chinese (Macao S.A.R.)                  zh-MO
zh-CHT       Chinese (Traditional)                   (no associated specific culture)
cs           Czech                                   cs-CZ
cs-CZ        Czech (Czech Republic)                  cs-CZ
da           Danish                                  da-DK
da-DK        Danish (Denmark)                        da-DK

*/

import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[] args)
    {
        // Prints the header.
        Console.WriteLine("CULTURE                                            "
            + " SPECIFIC CULTURE");
        
        // Determines the specific culture associated with each culture in the 
        // .NET Framework.
        for (int iCtr = 0; 
            iCtr < (CultureInfo.GetCultures(CultureTypes.AllCultures).length); 
            iCtr++) {
            CultureInfo ci = 
                CultureInfo.GetCultures(CultureTypes.AllCultures)[iCtr];
            Console.Write("{0,-12} {1,-40}", ci.get_Name(), 
                ci.get_EnglishName());
            try {
                Console.WriteLine("{0}", CultureInfo.CreateSpecificCulture(
                    ci.get_Name()).get_Name());
            }
            catch(System.Exception exp){
                Console.WriteLine("(no associated specific culture)");
            }
        }
    } //main
} //SamplesCultureInfo

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

CULTURE                                              SPECIFIC CULTURE
ar           Arabic                                  ar-SA
ar-SA        Arabic (Saudi Arabia)                   ar-SA
ar-IQ        Arabic (Iraq)                           ar-IQ
ar-EG        Arabic (Egypt)                          ar-EG
ar-LY        Arabic (Libya)                          ar-LY
ar-DZ        Arabic (Algeria)                        ar-DZ
ar-MA        Arabic (Morocco)                        ar-MA
ar-TN        Arabic (Tunisia)                        ar-TN
ar-OM        Arabic (Oman)                           ar-OM
ar-YE        Arabic (Yemen)                          ar-YE
ar-SY        Arabic (Syria)                          ar-SY
ar-JO        Arabic (Jordan)                         ar-JO
ar-LB        Arabic (Lebanon)                        ar-LB
ar-KW        Arabic (Kuwait)                         ar-KW
ar-AE        Arabic (U.A.E.)                         ar-AE
ar-BH        Arabic (Bahrain)                        ar-BH
ar-QA        Arabic (Qatar)                          ar-QA
bg           Bulgarian                               bg-BG
bg-BG        Bulgarian (Bulgaria)                    bg-BG
ca           Catalan                                 ca-ES
ca-ES        Catalan (Catalan)                       ca-ES
zh-CHS       Chinese (Simplified)                    (no associated specific 
culture)
zh-TW        Chinese (Taiwan)                        zh-TW
zh-CN        Chinese (People's Republic of China)    zh-CN
zh-HK        Chinese (Hong Kong S.A.R.)              zh-HK
zh-SG        Chinese (Singapore)                     zh-SG
zh-MO        Chinese (Macau S.A.R.)                  zh-MO
zh-CHT       Chinese (Traditional)                   (no associated specific 
culture)
cs           Czech                                   cs-CZ
cs-CZ        Czech (Czech Republic)                  cs-CZ
da           Danish                                  da-DK
da-DK        Danish (Denmark)                        da-DK
*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.