mardi 19 juin 2018

C# Checkbox with if else condition and && logical operator

I need some help with you :(. 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. Its only working in single condition like

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

Sorry for my bad english.

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