Possible Duplicate:
(object) is a 'field' but is used like a 'type'
As you might have guessed from the title am I getting this error:
Invasion_server.variables.resources is a field but is used like a type
The code that is giving me that error is:
class variables
{
....
public static string[] resources = new string[30];
resources[0] = "cities_wood";
....
}
Could someone please tell me what is causing the problem, because elsewhere in the code it is working…
If you would like to initialize the members of the array outside of a constructor or method body, you would need to do so using the initializer syntax with the declaration:
The downside to doing so is that you’d be required to populate all 30 values. If you’re looking to just populate the first, then you’ll need to do so either in a constructor or method body. You could consider a static constructor, which would have the same net effect as initializing when declared; the static constructor is run the first time a member of the class is accessed. For example: