修饰符private对此项无效c#

时间:2013-11-11 16:21:53

标签: c#

我有the modifier "private" is not valid for this item c#错误 请帮助我试图为土耳其(国家)制作学校笔记计算器

不工作:(

public partial class Form1 : Form
{
    string not;
    public Form1()
    {
        InitializeComponent();
    }

    private void textBox7_TextChanged(object sender, EventArgs e)
    {

    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {

    }

    private void label1_Click(object sender, EventArgs e)
    {

    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
       not = (label1.Text+label2.Text+label3.Text+label4.Text+label5.Text+label6.Text);
       label7.Text = not;
    }
    private void ConsoleApplication2.Form1_KeyDown(object sender, KeyEventArgs e);//ERROR\\
    }
    }

  }
}

2 个答案:

答案 0 :(得分:2)

更改

private void ConsoleApplication2.Form1_KeyDown(object sender, KeyEventArgs e);
}
}

private void ConsoleApplication2.Form1_KeyDown(object sender, KeyEventArgs e)
{
}

答案 1 :(得分:0)

您在第二种方法结束时放置了额外的半冒号。您需要正确格式化代码(为了便于阅读)并在第二次方法声明后删除分号。 改变

 private void button1_Click(object sender, EventArgs e)
    {
       not = (label1.Text+label2.Text+label3.Text+label4.Text+label5.Text+label6.Text);
       label7.Text = not;}
private void ConsoleApplication2.Form1_KeyDown(object sender, KeyEventArgs e);//ERROR\\
    }
}

 private void button1_Click(object sender, EventArgs e)
 {
       not = (label1.Text+label2.Text+label3.Text+label4.Text+label5.Text+label6.Text);
       label7.Text = not;
 }
 private void ConsoleApplication2.Form1_KeyDown(object sender, KeyEventArgs e)//;//ERROR\\
 {
 }