开发者

In what order are the static constructors of parent and child classes called?

开发者 https://www.devze.com 2023-02-15 11:06 出处:网络
In what order are the static constructors of parent and child classes called? class A{ static A() { MessageBox.Show(\"Yaht\"); } }

In what order are the static constructors of parent and child classes called?

class A     { static A() { MessageBox.Show("Yaht"); } }
class B : A { static B() { MessageBox.Show("Zee");  开发者_如何学Go} }
class C : A { static C() { MessageBox.Show("Zey");  } }

static void Main()
{
    B b = new B();
    C c = new C();
}

I could test it right now... if I had a compiler available.


Output:

Zee
Yaht
Zey

..........

0

精彩评论

暂无评论...
验证码 换一张
取 消