Export (0) Print
Expand All
0 out of 235 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
Not applicable.

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

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-Hans" or "zh-Hant".

NullReferenceException

name is null.

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

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
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-Hans      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-Hant      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-Hans      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-Hant      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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.