I was wondering why ReSharper does warn me, when I'm trying to convert a char to a string without giving a specific culture info.
Is there any case, where it could be converted differently on two systems?
Example:
var str = ' '.ToString();
The following ReSharper warning will pop up by default:
Specify a culture in string conversion explicitly.
This is because ReSharper sees that the type implements IConvertible
which has ToString(IFormatProvider)
.
System.Char
by itself does not expose a public method with that signature, even though the documentation indicates it does:
If you look at the overload with the IFormatProvider
parameter you will see this notice:
Implements
IConvertible.ToString(IFormatProvider)
and this remark:
The provider parameter is ignored; it does not participate in this operation.
ReSharper just notices the presence of that method, and the call to ToString
without a IFormatProvider
and thus complains, in this case you can safely disregard it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With