© { JSL }
20
Text Box: static Constructor
static Constructor
Folded Corner:
·a static c'tor initialises the type
wcan initialize static fields but not const fields
wcalled by VES when the type is loaded
wcannot 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