I have a class C with some internal variables. It has a nested class N that wants to access the variables in C. Neither C nor N are static, although C has some static methods and variables. When I try to access a non-static variable in C from N I get the squiggly underline and the message "Cannot access non-static field [fieldname] in static context".
This seems to have something to do with the nested class, since I can access the variable fine from the enclosing class itself.
ReSharper suggests I make _t static but that isn't an option. How do I deal with this?
public sealed partial class C
{
string _t;
class N
{
void m()
{
_t = "fie"; // Error occurs here
}
}
}