Is Int32.ToString() culture-specific?

后端 未结 7 1059
名媛妹妹
名媛妹妹 2020-11-30 09:47

I\'m running a beta version of ReSharper, and it\'s giving me warnings for the following code:

int id;
// ...
DoSomethingWith(id.ToString());
相关标签:
7条回答
  • 2020-11-30 10:22

    As tested on a random sample of ints, all 352 cultures installed with Windows (CultureTypes.InstalledWin32Cultures) give identical results.

    Daniel is right to note a custom culture could use a different prefix for negative numbers, but I doubt anyone has ever used this feature save by accident.

    I guess the .NET devs did it to be consistent with float and other types. What else were they expecting?

    > int.MaxValue.ToString(CultureInfo.AncientRome)
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM....
    
    0 讨论(0)
提交回复
热议问题