I have the following code:
public class Button{
static int Widest;
static int Height;
.
.
.
static public void Calc(int c,int w,int ih,int th,int m,int sw,int sh){
.
.
.
}
}
.
.
.
Button b1 = new Button(tCancel ,can,st);
Button b2 = new Button(tRestart,res,st);
Button b3 = new Button(tExit ,exi,st);
Button.Calc(3,b1.Wider(b2.Wider(b3)),Font2,Font0,MarginY,Width,Height); // this line generates an error!
This code generates the following error:
error CS0119: Expression denotes a method group', where a
variable’, value' or
type’ was expected
However I don’t understand why… If I make Calc non staic like this:
public void Calc(int c,int w,int ih,int th,int m,int sw,int sh){
.
.
.
}
and I call it like this:
b1.Calc(3,b1.Wider(b2.Wider(b3)),Font2,Font0,MarginY,Width,Height); // this compiles OK!
then no error is reported.
Since Calc only affects static varibles inside Button, the logical thing is to make it static, however if I declare it static it simply won’t compile… I have lots of static funtions declared, and lots of static function calls either, but this is the only one that gives me trouble… And I can’t figure out why.