Mrrm, gotta love .NET
-
This isn't a new annoyance. Just every time I have to deal with it I get all riled up. In the C# language
true
falsebut
true.ToString() == "True"
false.ToString() == "False"Of course xml is "true" and "false" http://www.w3.org/TR/xmlschema-2/#boolean[^] Whomever At Microsoft Decided That Everything No Matter What Should Start With A Capital Letter Should Be Dragged Outside And Shot.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.I would have to say, having read most of the previous replies, that this is one of those cases where there is more than one way to perform one operation. In this case, converting a non-string into a string value. Saying that the returned value from
Boolean.ToString()
should be lower-case just because XML defines the string definition of a Boolean as such, means that at some point, when you expect upper-case, the framework is again unreliable. As pointed out, and the XML classes in .NET, such asXmlWriter
, already do, you can use theXmlConvert
class to get a XML representation. For example, when using anXmlWriter
, there is aWriteValue(bool value)
method, which will handle the conversion in a similar manner. -
The real problem is not that ToString returns "True" and "False". Rather I think the real issue us that there is no way to get a culture specific string from a Boolean. even
ToString(IFormatProvider )
ignores culture.Could I suggest you look at CultureInfo Class[^] for more details on culture specific formatting. Specifically, look at the TextInfo property and what it represents. You should then understand why your statement is incorrect in this circumstance.
-
This isn't a new annoyance. Just every time I have to deal with it I get all riled up. In the C# language
true
falsebut
true.ToString() == "True"
false.ToString() == "False"Of course xml is "true" and "false" http://www.w3.org/TR/xmlschema-2/#boolean[^] Whomever At Microsoft Decided That Everything No Matter What Should Start With A Capital Letter Should Be Dragged Outside And Shot.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.Gotta say, every time I try and do anything to 'connect' to other (normally non MS) technologies in .NET I end up creating simple wrappers around alot of the types. This would be another potential case - just to override the default ToString implemtation.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)