I'm working on something in c# and I get an error when I try to execute this code
Code:
Form form3 = new Form3();
form3.Show;
Heres the error I get
Error:
only assignment ,call ,increasement ,decreasement ,and new object expressions
can be used as a sta开发者_JS百科tement
I usually dont get this error when I'm coding & thanks in advance
Just a typo, man:
Form form3 = new Form();
You called Form
, Form3
when you called the constructor.
=)
EDIT: You also weren't calling the Show
and close
functions properly:
private void button1_Click_1(object sender, EventArgs e)
{
Form form3 = new Form();
form3.Show();
this.Close();
}
form3.Show
looks like the culprit. It should be form3.Show()
. Without the parens it doesn't execute the method.
精彩评论