how to init my static variable like Java

  • Thread starter Thread starter Wu JianHua
  • Start date Start date
W

Wu JianHua

Hi£¬ I am new to C#, in Java I can code as following.

class MyClass
{
public static MyClass C1 = null;
public static MyClass C2 = null;

private MyClass
{
}

static
{
// init C1 and C2 here.
}

......
}

How to code in C#, please help me.
Thanks.

wu jianhua.
 
Marc Gravell said:
The static constructor takes the form

static MyClass() {

}

Marc

And you should either initialize the variable inline, or in the static
constructor, but not both.
 
Back
Top