[英]Should I care about culture, when my app will not emigrate?
ReSharper wants to change this: ReSharper希望更改此设置:
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. 无论您做什么,使用
InvariantCulture
都是安全的。 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. 考虑到这设置了一个“ id”,我个人很可能将文化强制为
InvariantCulture
,以确保以后不会得到奇怪的结果。
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. 另外-由于您使用的是ReSharper,因此已经在警告您。 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.
遵守良好的编码标准实际上比忽略警告要容易得多,这使得很难考虑不指定文化的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.