Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select>
items.
Calling int.ToString()
can result in digits outside the range [0-9]
in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)
).
Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?
Update: It appears that integer formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.