简体   繁体   中英

Should I care about culture, when my app will not emigrate?

ReSharper wants to change this:

platypusID = DuckbillValues[i - 1].ToString();

..to this:

platypusID = DuckbillValues[i - 1].ToString(CultureInfo.InvariantCulture);

Since the chances are great that my app will only be used in the US, which of the following would I be to acquiesce:

1) Smart
2) Dumb
3) Neither smart nor dumb
4) Smart, but not for that reason
5) Dumb, but not for that reason

Since the chances are great that my app will only be used in the US

Even if you're app is only used in the US, there's always a chance, if you're targeting a large audience, that a user could customize their regional settings or have their system setup using a different region.

Using InvariantCulture will be safe no matter what you're user does. Given that this is setting an "id", I, personally, would most likely force the culture to InvariantCulture in order to guarantee that I won't get a strange result later.

This also makes it easier in the future to support other regions... You never know what will happen later with your code, whether in this application or in others.

Also - since you're using ReSharper, it's already warning you about this. You're already there. It's actually easier to comply with good coding standards than it would be to ignore the warning, which makes it difficult to think of a reason NOT to specify the culture.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM