© { JSL }
19
Text Box: static Fields
static Fields
·to declare static fields of other types
wuse static keyword!
wstatic fields are default initialised
wstatic fields can use variable initialisers
waccess is via typename only
class Pair
{
... static Pair origin;
... static Pair topLeft = new Pair(10,20);
... static AnyClass field;
... static string both = "Arthur";
}
Pair p = new Pair();
...
F(p.Origin);    // compile-time error
F(Pair.Origin); // OK