CultureInfo.Name Property

May 11, 2014

Gets the culture name in the format "languagecode-country/regioncode".

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

public virtual string Name { get; }

Property Value

Type: System.String
The culture name in the format "languagecode-country/regioncode", where languagecode is a lowercase two-letter code derived from ISO 639-1 and country/regioncode is an uppercase two-letter code derived from ISO 3166.

For a list of predefined culture names and identifiers that the Name property can return, see the National Language Support (NLS) API Reference at the Go Global Developer Center. Note that culture names are subject to change.

The CultureInfo.Name property follows the naming standards provided in the CultureInfo class topic.

The Name property always returns a "short" form of the name that excludes any indication of an alternate sort order. For example, if a CultureInfo object is instantiated for the de-DE_phoneb culture, the Name property returns the string "de-DE".

To get the full name of the culture, you can retrieve the value of the DisplayName, EnglishName, or NativeName property.

The following example displays the Name property as well as the DisplayName and NativeName properties of several cultures.


using System;
using System.Globalization;
using System.Windows.Media;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.FontFamily = new FontFamily("Courier New");

      string[] cultureStrings= {"nl-NL", "en", "en-US", "fr-FR", 
                                "de-DE", "ru-RU", "sr-Cyrl-CS",  
                                "sr-Latn-CS", "es-MX", "sv-SE"};
      outputBlock.Text += String.Format("{0,-15} {1,-15} {2,-30} {3,-30}\n\n", 
                                        "Culture", "Name", "DisplayName", 
                                        "NativeName"); 
      foreach (string cultureString in cultureStrings)
      {
         try {
            CultureInfo ci = new CultureInfo(cultureString);
            outputBlock.Text += String.Format("{0,-15} {1,-15} {2,-30} {3,-30}\n", 
                                              cultureString + ":", ci.Name, 
                                              ci.DisplayName, ci.NativeName);
         }
         catch (ArgumentException) {
            outputBlock.Text += String.Format("Unable to create the {0} culture.\n", cultureString);
         }
      }                                        
   }
}
// The example displays the following output:
//    Culture         Name            DisplayName                    NativeName                    
//    
//    nl-NL:          nl-NL           Dutch (Netherlands)            Nederlands (Nederland)        
//    en:             en              English                        English                       
//    en-US:          en-US           English (United States)        English (United States)       
//    fr-FR:          fr-FR           French (France)                français (France)             
//    de-DE:          de-DE           German (Germany)               Deutsch (Deutschland)         
//    ru-RU:          ru-RU           Russian (Russia)               русский (Россия)              
//    sr-Cyrl-CS:     sr-Cyrl-CS      Serbian (Cyrillic, Serbia)     српски (Србија)               
//    sr-Latn-CS:     sr-Latn-CS      Serbian (Latin, Serbia)        srpski (Srbija)               
//    es-MX:          es-MX           Spanish (Mexico)               Español (México)              
//    sv-SE:          sv-SE           Swedish (Sweden)               svenska (Sverige)             


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft