© { JSL }
20
static Constructor
·
a
static
c'tor initialises the type
w
can initialize
static
fields but not
const
fields
w
called by VES when the type is loaded
w
cannot be called, no access modifier allowed
class
GoodExample
{
static
GoodExample()
{
origin =
new
Pair(0,0);
}
...static readonly
Pair origin;
}
OK
class
BadExample
{
public
static
GoodExample()
{
x = 42;
}
...const int
x;
}
compile
time
errors