mardi 19 juin 2018

Checkbox with if else condition and && logical operator

I don't know what is going on with my condition. I know the statement is true but there is bug and I really don't know why my codes are not working properly. When the checkbox 1 and checkbox 2 were checked, its not working. It's only working in single condition like

if (chk1.Checked == true)
{
    Toast.MakeText(this, "Extra Rice", ToastLength.Short).Show();
}

Here is my code:

if (chk1.Checked == true)
{
    Toast.MakeText(this, "Extra Rice", ToastLength.Short).Show();
}
else if ((chk1.Checked == true) && (chk2.Checked == true))
{
    Toast.MakeText(this, "full rice & Extra Sauce", ToastLength.Short).Show();
}
else if ((chk1.Checked == true) && (chk3.Checked == true))
{
    Toast.MakeText(this, "full rice & Extra Rice", ToastLength.Short).Show();
}
else if ((chk2.Checked == true) && (chk3.Checked == true))
{
    Toast.MakeText(this, "Extra Sauce & Extra Rice", ToastLength.Short).Show();
}
else if ((chk1.Checked == true) && (chk2.Checked == true) && (chk3.Checked == true))
{
    Toast.MakeText(this, "full rice | Extra Sauce | Extra Rice", ToastLength.Short).Show();
}

Aucun commentaire:

Enregistrer un commentaire