Why does Convert.ToBoolean("0") fail?
Posted
by JL
on Stack Overflow
See other posts from Stack Overflow
or by JL
Published on 2010-05-17T23:47:34Z
Indexed on
2010/05/18
0:10 UTC
Read the original article
Hit count: 112
c#
I know that trying to convert string "0" to boolean will fail, I also know how to fix this, thanks to Jon Skeets answers on other questions.
What I would like to know is WHY does C# not recognize "0" as a valid input for a boolean conversion, surely you could look at it like 0 = false, 1 = true, or even -1 = false and 0 = true, anyways, my logic tells me that it could be a valid input, so is there a very good reason why its not? My bet is old vb6 would be able to recognize the string input "0" as valid.
© Stack Overflow or respective owner