I have snippets from Form1 and a class named netclass.cs (just an
arbitrary name.)
Form1 has a textBox1 on it. I want to reference it in the class. I
put:
static void Main()
{
Application.Run(new Form1());
netclass nc = new netclass(this);
netclass.StartClient();
}
In the netclass class:
public class netclass
{
static Form1 _Form;
public netclass(Form1 form)
{
_Form = form;
//
// TODO: Add constructor logic here
//
}
I get the error:
Keyword this is not valid in a static property, static method, or
static field initializer
(and it is talking about the keyword "this")
If I change the "static Form1 _Form;" to just "Form1 _Form;" I get
past that error, but then I get another error when I try an use the
_Form textBox1:
string temp = _Form.textBox1.Text; //in netclass.cs just want to get
the text
I can't figure out what to put to make them both go away.
Thank you for any help.