Question

We have code in our system to format numbers and currency according to the regional settings selected by the user. One of our users has selected en-ZA and noticed that the digit grouping and decimal separators have changed with our migration to .NET 4.0.

I wrote a snippet of code to illustrate this change:

using System;
namespace regional
{
    class Program
    {
        static void Main(string[] args)
        {
            var ci = new System.Globalization.CultureInfo("en-ZA");
            var output = 1234567.00m.ToString("c", ci);
            Console.WriteLine(output);            
        }
    }
}

Under .NET 3.5, we get output that looks like this:

R 1,234,567.00

Under .NET 4.0, we get output that looks like this:

R 1 234 567,00

What accounts for the change in decimal separator and digit grouping between .NET 3.5 and .NET 4.0?

According to Wikipedia, "When South Africa adopted the metric system, it adopted the comma as its decimal separator." This implies that this setting changed at some point, but I still don't have insight as to why the behavior is different between the different framework versions.

Was it helpful?

Solution

The .net team review stuff like this based on consumer feedback - presumably enough people petitioned them to say the existing settings were incorrect so they changed them.

http://msdn.microsoft.com/en-us/library/dd997383.aspx#updated_globalization_property_values

basically says "we update globalization settings between versions", and

http://msdn.microsoft.com/en-us/library/dd997383.aspx#getting_current_globalization_information

says that from Windows 7 onwards they in fact load globalization data from the OS (so potentially en-za will appear differently under different operating systems, at different points in time). Also

Because of the ever-changing world, globalization information is subject to change at any time; developers should not expect the values of globalization properties to persist between releases, or even for the same release of the .NET Framework

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top