compiler errors - C# - Why can't I change my int variables in another class? -
okay, have following variables:
public static int cookiecount = 0; public static int cursorcount = 0; public static int grancount = 0; public static int farmcount = 0; public static int minecount = 0; public static int shipcount = 0; public static int alccount = 0; public static int portalcount = 0; public static int timecount = 0; public static int clickgain = 1; public static int cursorgain = 1; public static int grangain = 5; public static int farmgain = 10; public static int minegain = 50; public static int shipgain = 100; public static int alcgain = 500; public static int portalgain = 10000; public static int timegain = 123456; public static int cursorprice = 20; public static int granprice = 100; public static int farmprice = 500; public static int mineprice = 1000; public static int shipprice = 10000; public static int alcprice = 50000; public static int portalprice = 500000; public static int timeprice = 1500000; public static float cursorspeed = 1f; public static float granspeed = 2f; public static float farmspeed = 5f; public static float minespeed = 5f; public static float shipspeed = 10f; public static float alcspeed = 15f; public static float portalspeed = 10f; public static float timespeed = 15f;
and have in global.cs. when i'm in form1 use this:
private void cookie_click(object sender, eventargs e) { global.cookiecount + global.clickgain; }
i error.
only assignment, call, increment, decrement, , new object expressions can used statement.
so common sense tells me static varibles not changeable, changing static dynamic throws these errors:
invalid token 'int' in class, struct, or interface member declaration
only assignment, call, increment, decrement, , new object expressions can used statement
'cookieclicker.global.cookiecount' inaccessible due protection level
an object reference required non-static field, method, or property
i'm stumped on how this.
all want when cookie_click runs, global.clickgain added cookiecount, want variables global.
you not assigning result anything.
assign result global.cookiecount
, this:
global.cookiecount += global.clickgain;
or this
global.cookiecount = global.cookiecount + global.clickgain;
Comments
Post a Comment