Reputation: 2493
I'm using this code
Thread T = new Thread(new ThreadStart(Listen));
T.IsBackground = true;
T.Start();
And its returning these errors;
[Line 2] Invalid token '=' in class, struct, or interface member declaration [Line 3] Invalid token '(' in class, struct, or interface member declaration
Can someone shed some light on whats going wrong here because I don't really know what is.
Upvotes: 0
Views: 51
Reputation: 391604
You're writing those 3 lines inside a class, and not inside a method of that class.
This will produce that error:
public class Dummy
{
Thread T = new Thread(new ThreadStart(Listen));
T.IsBackground = true;
T.Start();
...
}
This will not:
public class Dummy
{
public void Test()
{
Thread T = new Thread(new ThreadStart(Listen));
T.IsBackground = true;
T.Start();
}
...
}
Upvotes: 4