int value only consist out of 1 or 0.
I can solve the problem by writing a
if else statement.
Isn't there a way to cast the
int into a
This question is tagged with
~ Asked on 2013-02-27 09:40:59
false (which is the case in a lot of programming languages). That means
not 0 (some languages use
-1 some others use
1; doesn't hurt to be compatible to either). So assuming by "better" you mean less typing, you can just write:
bool boolValue = intValue != 0;
~ Answered on 2013-02-27 09:43:51
int i = 0; bool b = Convert.ToBoolean(i);
~ Answered on 2013-02-27 09:42:55