We've talked about localization before. Maybe it's just really hard to remember that some people use symbols differently than you do. Luckily, most modern languages have tools to help us deal with rules we never wanted to know about; in .Net, this all lives in System.Globalization.

Esteban recently came across a good example of how to be sensitive to the way other people use commas and periods.

What often seems to be the most difficult is the decimal separator, especially for the person who wrote this code. I found it during a review to verify that specification changes had been implemented in a lot of old code.

  string maxValue;

  CultureInfo culture = 
System.Threading.Thread.CurrentThread.CurrentCulture;
  if (culture.NumberFormat.CurrencyDecimalSeparator == ",")
  {
      maxValue = "999999,99";
  }
  else
  {
      maxValue = "999999.99";
  }

  if (currentValue<0||currentValue>(decimal.Parse(maxValue, culture))) //m
  {
     // ...
  }

Luckily, the single comment in the original code was extremely helpful.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!