this is my full code :
chkbody.checked=true?prodid=ddlprod.getID:prodid=-1;
Error cannot implicitely convert type double to bool
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 20, 2013, 5:09 AM
prodid = chkbody.Checked ? ddlprod.getID : -1;
Jaganathan BantheswaranPosted Nov 21, 2013, 6:11 AM
This is what he want,
var prodid = chkbody.Checked ? ddlprod.getID : -1;
@Mohammed,
Please make the reply as Answer, if that helped you.
Girish SapariyaPosted Nov 20, 2013, 5:25 AM
yes Vulpes, me too suspect same,
Mohammed is it so that you are trying to set prodid = -1 if checkbox uncheck, and prodid = Convert.ToDouble(value) if checkbox is checked, then u should go with Vulpes solution, it will work.
Jignesh TrivediPosted Nov 20, 2013, 5:25 AM
if(chkbody.Checked)
{
prodid = Convert.ToDouble(ddlprod.getID);
}
else
{
prodid = -1;
}
hope this will help you.
mohammed shamsheerPosted Nov 20, 2013, 4:52 AM
Jignesh TrivediPosted Nov 20, 2013, 4:18 AM
agree with Girish, C# language does not able to implicitely convert type, so try Girish suggetion.
Get back to us if it is not working..
Girish SapariyaPosted Nov 20, 2013, 2:06 AM
u need to type cast it
e.g
double d = 1.5;
bool flag = Convert.ToBoolean(d);
Jaganathan BantheswaranPosted Nov 20, 2013, 2:03 AM
We assume that you are trying to convert the double value to bool.
Use bool.TryParse method to convert any value to boolean.
it will return false if the conversion failed else the converted value will be in the out param you passed to TryParse.