I'm trying to create a gym membership with various radio buttons as different options. I want the user to be able to select the calculate button and the cost to appear in the text box but for some reason my if the statement is adding all the radio button costs together instead of just the one the user selects.
private void calculatebutton_click(object sender, eventargs e)
{
int membershipcost = 0;
if (basicradiobutton.checked);
membershipcost += 10;
if (regularradiobutton.checked);
membershipcost += 15;
if (premiumradiobutton.checked);
membershipcost += 20;
membershipcosttxtbx.text = membershipcost.tostring();
Aucun commentaire:
Enregistrer un commentaire