I'm trying to add values of phones numbers based on checkbox's in the UI. For example if a checkbox1 (which represent phone1) is checked and checkbox2 is also checked then the program will add both phones' values. How can I add the value (in for loop for example) so that the if statement is lesser and simplified.
Here is my code:
public double totalPhone()
{
double total = 0;
double item1 = 2249;
double item2 = 1769;
double item3 = 3099;
double item4 = 1198;
double item5 = 1899;
if (chkPhone1.Checked == true)
{
total = total + item1;
}
if (chkPhone2.Checked == true)
{
total = total + item2;
}
if (chkPhone3.Checked == true)
{
total = total + item3;
}
if (chkPhone4.Checked == true)
{
total = total + item4;
}
if (chkPhone5.Checked == true)
{
total = total + item5;
}
return total;
}