Why .NET Boolean has TrueLiteral and TrueString?

Posted by user309937 on Stack Overflow See other posts from Stack Overflow or by user309937
Published on 2010-04-06T10:53:12Z Indexed on 2010/04/06 11:03 UTC
Read the original article Hit count: 310

Filed under:
|
|
|
|

Why in Boolean type there are two fields with the same value?

internal const int True = 1;
internal const int False = 0;
internal const string TrueLiteral = "True";
internal const string FalseLiteral = "False";

and

public static readonly string TrueString;
public static readonly string FalseString;

static Boolean()
{
    TrueString = "True";
    FalseString = "False";
}

in reflector generated code, methods don't use those strings but:

public string ToString(IFormatProvider provider)
{
    if (!this)
    {
        return "False";
    }
    return "True";
}

would't it be better to use those const values?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about boolean