Does CultureInfo.CurrentCulture.Name always return the language code and country/region code separated by a hyphen?

242 Views Asked by At

Does CultureInfo.CurrentCulture.Name always return the language code and country/region code separated by a hyphen? I have been told that CultureInfo.CurrentCulture.Name can sometimes return just the two letter language code, but I have found no documentation to substantiate this claim.

1

There are 1 best solutions below

0
cpdev On

Thank you Jimi for your reference to neutral culture. I found the following example that demonstrating a neutral culture, where only "fr" is specified, and therefore CultureInfo.CurrentCulture.Name will only return the two-character language code:

   public static void Main()
   {
      double value = 1634.92;
      CultureInfo.CurrentCulture = new CultureInfo("fr-CA");
      Console.WriteLine("Current Culture: {0}",
                        CultureInfo.CurrentCulture.Name);
      Console.WriteLine("{0:C2}\n", value);

      Thread.CurrentThread.CurrentCulture = new CultureInfo("fr");
      Console.WriteLine("Current Culture: {0}",
                        CultureInfo.CurrentCulture.Name);
      Console.WriteLine("{0:C2}", value);
   }


// The example displays the following output:
//       Current Culture: fr-CA
//       1 634,92 $
//
//       Current Culture: fr
//       1 634,92 €