CultureInfo.Name Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Overridable ReadOnly Property Name As String
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.

Remarks

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.

Examples

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

Imports System.Globalization

Public Module Example
   Public Sub Demo(outputBlock As System.Windows.Controls.TextBlock)
      outputBlock.FontFamily = New FontFamily("Courier New")

      Dim cultureStrings() As String = {"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}", _
                                        "Culture", "Name", "DisplayName", _
                                        "NativeName") + vbCrLf + vbCrLf
      For Each cultureString As String In cultureStrings
         Try
            Dim ci As New CultureInfo(cultureString)
            outputBlock.Text += String.Format("{0,-15} {1,-15} {2,-30} {3,-30}", _
                                              cultureString + ":", ci.Name, _
                                              ci.DisplayName, ci.NativeName) + vbCrLf
         Catch e As ArgumentException
            outputBlock.Text += String.Format("Unable to create the {0} culture.", _
                                              cultureString) + vbCrLf
         End Try
      Next                                        
   End Sub
End Module
' 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)             
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)             

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.