bit to bool

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Greeting,
i receive from db parameter in bit format
and tried to convert it to boolean:
bool boolBhcg=(bool)prmBhcg.Value;

as result i receive msg:

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

does anyone meet this problem before?
 
Mike said:
does anyone meet this problem before?

A bool can only have one of two values: true or false. Unlike other
languages, a non-zero value does not indicate a true condition. Try
something like this instead:

bool boolBhcg = (prmBhcg.Value != 0);

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top