An object reference is required.

Solved
sime -  
 lepirate -
Hello,

I have these two lines of code:

int[] tab = new int[6];
tab = function(arg1, arg2);

Knowing that the function returns an integer array of size 6, I get the following error:

An object reference is required for the non-static property, method, or field 'function(arg1, arg2)'

Thank you for your help.

4 réponses

feadin91 Posted messages 282 Status Membre 89
 
Hello,

You have probably solved your problem by now, but I'm posting the solution for those who will search later (like me)

This topic being the first result of a Google search on this error, I think it's useful to point that out.

You just need to declare your FUNCTION as STATIC ;)

-> public static int[] Function(int arg1, int arg2)
{...}

Best regards
--
The spoon does not exist!
75
echo
 
Hello,

I know it's been a while, but I've just encountered this problem and your solution really helped me.
Would you have an explanation?

Best regards,
0
Kuraanal
 
Thank you for the explanation =p
0
lepirate
 
Thank you very much.
0