Playing around in Mono 2.10 REPL:
csharp> string a = "true";
csharp> a.ToBoolean(CultureInfo.InvariantCulture);
{interactive}(1,4): error CS1061: Type `string' does not contain a definition fo
r `ToBoolean' and no extension method `ToBoolean' of type `string' could be foun
d (are you missing a using directive or an assembly reference?)
C:\PROGRA~1\MONO-2~1.2\lib\mono\4.0\mscorlib.dll (Location of the symbol related
to previous error)
csharp> ((IConvertible)a).ToBoolean(CultureInfo.InvariantCulture);
true
csharp>
According to docs, System.String
implements IConvertible. If this is true, why does
a.ToBoolean(CultureInfo.InvariantCulture);
fail?
Why do I have to cast it to IConvertible to make ToBoolean work?