输出的为X= 1 ,Y = 0;
public class A
{
public A()
{
PrintFields();
}
public virtual void PrintFields()
{}
}
public class B : A
{
int x = 1;
int y;
public B()
{
y = -1;
}
public override void PrintFields()
{
Console.WriteLine("x={0},y={1}", x, y);
}
}
class Program
{
static void Main(string[] args)
{
B b = new B();
Console.ReadLine();
}
}
输出的为X= 1 ,Y = 0;