Why does ReSharper warn about Char.ToString () unless explicitly specifying CultureInfo?

I was wondering why ReSharper warns me when I try to convert char to string without specifying specific culture information.

Is there a case where it can be converted differently into two systems?

Example:

var str = ' '.ToString(); 

By default, a ReSharper warning appears:

Define culture in string conversion explicitly.

+7
c # resharper cultureinfo
source share
2 answers

This is because ReSharper sees that the type implements IConvertible , which has ToString(IFormatProvider) .

System.Char itself does not provide a public method with this signature, although the documentation indicates what it does:

Char.ToString overloads

If you look at the overload with the IFormatProvider parameter, you will see this notification:

Implements
IConvertible.ToString(IFormatProvider)

and this remark:

The provider parameter is ignored; he is not involved in this operation.

ReSharper just notices the presence of this method and calls ToString without IFormatProvider and thus complains, in this case you can safely ignore it.

+10
source share

I found this http://csharpindepth.com/Articles/General/Strings.aspx

Some of the oddities of Unicode lead to strangeness in strings and character handling. Many of the string methods are culture sensitive - in other words, what they do depends on the culture of the current thread. For example, what do you expect to return "i" .toUpper ()? Most people will say “I”, but in Turkish the correct answer is “İ” (Unicode U + 0130, “Latin capital I with a dot above”)

-2
source share

All Articles