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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 20, 2013, 12:09 AM EST
prodid = chkbody.Checked ? ddlprod.getID : -1;
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 19, 2013, 9:03 PM EST
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.
Girish Sapariya159 reputationPosted Nov 19, 2013, 9:06 PM EST
u need to type cast it
e.g
double d = 1.5;
bool flag = Convert.ToBoolean(d);
Jignesh TrivediRank #16 · 50.3K reputationPosted Nov 19, 2013, 11:18 PM EST
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..
mohammed shamsheerRank #4,152 · 361 reputationPosted Nov 19, 2013, 11:52 PM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Nov 20, 2013, 12:25 AM EST
if(chkbody.Checked)
{
prodid = Convert.ToDouble(ddlprod.getID);
}
else
{
prodid = -1;
}
hope this will help you.
Girish Sapariya159 reputationPosted Nov 20, 2013, 12:25 AM EST
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.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 21, 2013, 1:11 AM EST
This is what he want,
var prodid = chkbody.Checked ? ddlprod.getID : -1;
@Mohammed,
Please make the reply as Answer, if that helped you.