private void btn_Click(object sender, EventArgs e)
{
//宣告金額的初始值為 0
int total = 0;
//主餐
if (chk1.Checked) total += 260;
if (chk2.Checked) total += 260;
if (chk3.Checked) total += 200;
if (chk4.Checked) total += 240;
//配菜
if (rdb1.Checked) total += 180;
if (rdb2.Checked) total += 160;
//飲料
if (rdb3.Checked) total += 40;
if (rdb4.Checked) total += 40;
if (rdb5.Checked) total += 70;
lblOutput.Text = "NT $ " + total;
}
※以上資料如有錯誤請多指教
書名:程式設計基本功與實務範例解析:使用C#(第三版)(附範例光碟)