Comma and (decimal) point: Do they need different handling?

Dante1986 picture Dante1986 · Jan 16, 2012 · Viewed 14.2k times · Source

Just something that i was wondering about. In Europe the comma us mostly used for decimals (like 20,001) but outside Europe the point is mostly used (like 20.001) How does c# handle this ? In case of a application that will be used by Europe and non-Europe people, do you need to worry about the above when programming ?

Just curious about this.

Answer

Greg Hewgill picture Greg Hewgill · Jan 16, 2012

As far as the programming language is concerned, the decimal point separator is always ., and the punctuation used to separate function arguments is always ,. Changing that based on the spoken language of the programmer would be too confusing.

For the user interface, there are formatting functions in the CultureInfo class that can produce a floating point number representation that uses the decimal point separator and thousands separator of your choice. (Or, for cultures that group digits of a number differently than in triplets, the formatting functions can handle that too.)