Re: Cannot convert type 'int' to 'bool'



I don't know why you get this error but it could be related with bool values being limited to 1 or 0. In this case, the int is 1, but I wouldn't want the compiler trying to determine stuff like that--too much overhead.

How about something like this:

bool isTrue = (test != 0);

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"John" <no@xxxxxxxx> wrote in message news:u9U4dJN$HHA.1900@xxxxxxxxxxxxxxxxxxxxxxx
The following code:

int test = 1;
bool isTrue = (bool)test;

results in a compiler error:

Cannot convert type 'int' to 'bool'

wtf, any ideas on how to work around this?

.



Relevant Pages


Loading