The following doesn't work because w and h need to be const's. I'm assuming Enums have to be set at compile time and can't be changed at run time. Is this a possibility, or is it better to just make foo a class?
class Bar
{
int w, h;
enum foo : int
{
a = w * h
}
public Bar(int w, int h)
{
this.w = w;
this.h = h;
}
}
enummember definitions must be compile time constants. Whether or notfoois better suited to be a class depends entirely upon how you're going to use it, really.intexplicitly: they already do it implicitly...enum myFirstInts { one, two, three }which you can use likemyFirstInts myFirstEnumVar = myFirstInts.one;or evenmyFirstInts myFirstEnumVar = 0;(-> it refers to one).