C#
I am working on a 2d hex map with XNA. Right now I am figuring out the math to correctly plotting hexes. I have a question on fields and their variables. Sometimes you can do simple math with variables like this
int something = 1 * 5;
however if we have something like this
we get an errorCode:int anumber = 2; int something = 1 * anumber;
***A field initializer cannot reference the non-static field, method, or property***
there seems to be 2 ways around it; I can do this
or thisCode:static int anumber = 2; int something = 1 * anumber;
Can somebody tell me the difference here? I need some sort of explanation on static fields and this other thing.Code:int something { get { int result = 1 * anumber; return result; } }




Reply With Quote