testInt declared as an instance field. The static method cannot access an instance field without reference to an instance of the defining class. So declare testInt as static or modify TestMethod to accept an instance of TestPage . So
protected static int testInt { get; set; }
good like
public static void TestMethod(TestPage testPage) { Console.WriteLine(testPage.testInt); }
Which one is correct depends a lot on what you are trying to model. If testInt represents the state of the TestPage instance, then use the latter. If testInt is something like TestPage , then use it.
jason
source share