Is Int32.ToString() culture-specific?

后端 未结 7 1074
名媛妹妹
名媛妹妹 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条回答
  •  萌比男神i
    2020-11-30 10:02

    It's weird; I would have expected 50.ToString(CultureInfo.CreateSpecificCulture("ar-AE")) to return "٥٠", but it doesn't.

    I've just looked this up, and the problem seems to be that NumberFormatInfo.DigitSubstitution isn't actually implemented

    The DigitSubstitution property is reserved for future use. Currently, it is not used in either parsing or formatting operations for the current NumberFormatInfo object.

    So, although there is an enumeration System.Globalization.DigitShapes, it's not actually implemented in the NumberFormatInfo bit of IFormatProvider.

提交回复
热议问题