I read the MSDN article of the boolean structure when I saw that the boolean has two fields: TrueString and FalseString . They respectively return "True" and "False".
After some searching, the only example I could find is in dotnetperls in this article . The article says:
Programs often need these lines. TrueString and FalseString are a useful pair of read-only members. They represent truth values โโin a string format. They provide indirect and abstraction directly using string literals.
So maybe this is useful for some situations. But the same article does not provide a realistic example (IMHO).
Some additional reading also caught my attention: TrueString and FalseString are readonly public static fields. And this dornetperls article reads:
The language specification recommends using readonly public static fields ... when the field may be changed in the future.
Now I can understand a little. If .NET developers ever decide to change "True" and "False" respectively to "OkeyDokey" and "Negative", it is wise to use TrueString and FalseString.
But that still leaves me with the question: in which scenario do you want to compare a string with a boolean string literal? Because clearly: โPrograms often needโ them.
c # boolean string-literals
Jordy
source share