[在几乎所有我使用'私人'或'公共'的情况下,我都会收到此错误。我最近将班级从[...]更改为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();
依此类推...
即使我将其从公共更改为私人,反之亦然,它仍然会引发此错误。
[在几乎所有我使用'私人'或'公共'的情况下,我都会收到此错误。我最近改变了班级,只好上课了。组;来自...公共字符串Title {get {return title; }设置{title = ...
您有一个嵌套函数,在C#中,这些称为局部函数,没有作用域。因此,您需要删除访问修饰符。
您也将示例中的属性更改为static
:public static string Title