1.初始化父类static成员
2.初始化子类static成员
3.初始化父类非static成员
4.初始化子类非static成员
5.调用父类构造器
6.调用子类构造器
//执行结果是 x=0,y=1
static void Main(string[] args)
{
//Console.WriteLine("Hello World!");
B cb = new B();
//Console.WriteLine(GetValue(30).ToString());
Console.Read();
}
class A
{
public A()
{
print();
}
public virtual void print()
{
}
}
class B:A
{
int x;
int y = 1;
public B()
{
y = -1;
}
public override void print()
{
Console.WriteLine("x={0},y={1}",x,y);
}
}
//递归
private static long GetValue(int n)
{
//1,1,2,3,5,8,13,21,34,55,89,144
if (n > 2)
{
return GetValue(n - 1) + GetValue(n - 2);
}
else
{
return 1;
}
}