true.ToString() false.toString(); Output: True False
Is there a valid reason for it being ‘True’ and not ‘true’? It breaks when writing XML as XML’s boolean type is lower case, and also isn’t compatible with C#’s true/false (not sure about CLS though).
Update
Here is my very hacky way of getting around it in C# (for use with XML)
internal static string ToXmlString(this bool b) { return b.ToString().ToLower(); }
Of course that adds 1 more method to the stack, but removes ToLowers() everywhere.
Only people from Microsoft can really answer that question. However, I’d like to offer some fun facts about it 😉
First, this is what it says in MSDN about the Boolean.ToString() method:
Here comes the fun fact #1: it doesn’t return TrueString or FalseString at all. It uses hardcoded literals ‘True’ and ‘False’. Wouldn’t do you any good if it used the fields, because they’re marked as readonly, so there’s no changing them.
The alternative method, Boolean.ToString(IFormatProvider) is even funnier:
What’s the solution? Depends on what exactly you’re trying to do. Whatever it is, I bet it will require a hack 😉