真的很愚蠢的问题因为我认为你不能这样做但
namespace Parking_Ticket_Fines
{
public partial class frmParking : Form
{
public frmParking()
{
InitializeComponent();
}
private void btnCal_Click(object sender, EventArgs e)
{
//Variable
int Total = 0;
//Checks which radio button is checked
if (radExpired.Checked)
{
Total = 35;
}
else if (radParking.Checked)
{
Total = 75;
}
else if (radDriveway.Checked)
{
Total = 150;
}
else if (radHandicap.Checked)
{
Total = 500;
}
}
private void btnClear_Click(object sender, EventArgs e)
{
//Clears everything
lblTotal.Text = "";
radRepeat.Checked = false;
radExpired.Checked = true;
}
有没有办法可以在两个私有空间中使用“Total”变量而不会两次声明它?
答案 0 :(得分:3)
有没有办法可以在两个私人空间中使用“总计”变量 没有两次宣布它?
是在班级宣布。
public partial class frmParking : Form
{
private int Total; //Here
public frmParking()
{
InitializeComponent();
}
此Total
字段会更多地显示Fields (C# Programming Guide)