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.
Is it worth the effort to use culture invariant string formatting in single-culture applications?
.net;internationalization;culture
Since the output will be exactly the same, this is a pretty subjective choice. If you know the application only ever will run in one specific culture, then I would say leave it out for simplicity.But if the application might be ported to multiple cultures, I would say leave it in. Even if you know all cultures you port to all have the same integer formatting, you should not require that all readers of the code know that, and without the knowledge, the code looks like a subtle bug. So make the intention clear in the code that the value is supposed to be invariant rather than culture specific. 