按照什么顺序父母与子女类的静态构造函数叫什么? [英] In what order are the static constructors of parent and child classes called?
本文介绍了按照什么顺序父母与子女类的静态构造函数叫什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在什么顺序父母与子女类的静态构造函数叫什么名字?
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"); } }
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.
推荐答案
输出:
Zee
Yaht
Zey
..........
..........
这篇关于按照什么顺序父母与子女类的静态构造函数叫什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文