在我使用“私人”或“公共”的几乎所有情况下,我都会遇到这个错误。我最近将我的课程改为 get; set;
从...
public string Title
{
get { return title; }
set { title = value; }
}
至...
public static string Title
{
get;
set;
}
有错误出现在...
private void cBxEmployment_SelectedIndexChanged_1(object sender, EventArgs e)
{
//sets the job list combo box to visible if "Employed" or "Self Employed" is selected by user, if not selected jobs list combo box is not visible.
if (cBxEmployment.SelectedIndex == 0 || cBxEmployment.SelectedIndex == 1)
{
lblJob.Visible = true;
cBxJob.Visible = true;
}
else
{
lblJob.Visible = false;
cBxJob.Visible = false;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
//when exit button is clicked user will get a message box asking if they want to exit, if yes program closes
DialogResult answer = MessageBox.Show("Would you like to exit?", "Exit", MessageBoxButtons.YesNo);
if (answer == DialogResult.Yes)
{
//close program
Application.Exit();
}
}
private void btnClear_Click(object sender, EventArgs e)
{
cBxTitle.SelectedIndex = -1;
txtFName.Text = "";
txtLastname.Text = "";
txtDOB.ResetText();
cBxEmployment.SelectedIndex = -1;
cBxJob.SelectedIndex = -1;
cBxRelationship.SelectedIndex = -1;
cBxTitle.Focus();
等等...
即使我将其从公共更改为私人,反之亦然,它仍然会引发此错误。