If I have a class,any member in it that I don’t declare static will have this error if I reference it inside the class:
An object reference is required for the non-static field, method, or
property
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will get that error if you are accessing a instance method from a static context. For example
Instead you need to create an instance of the class
However, a mix-up like this might suggest a misunderstanding of C# semantics and I’d recommend picking up any one of the intro to C# books on Amazon to get a better understanding.