Me n My Programming

If Only I Have TIme

An object reference is required for the non-static field, method

What is this error? I just found it and never found it before. I never though you need to declare your method as a static method if it does not return any value. Last time when you declare a method static, the method that is call from inside that method does not required to be static also. This time (.Net 3.5), you need to declare it also as static. Not just that, the content also need to be some kind of static type. Let me show you an example:

private static int method1(…) {

//do something


private void method2(…) {

//do something


private void main(…){

int a = method1();



This kind of error will fire up and tell you to declare static. For me, it is a good practice to declare static to make sure the data does not change (we never what happen inside buffer) but at any other time, you just do not need to declare everything static. To solve this problem, I just delete the static statement. As simple as that. Maybe if I got time, I will as it suggested.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


This entry was posted on September 10, 2008 by in C#.
%d bloggers like this: