- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- B b = new B();
- Console.ReadKey();
- }
- }
- class A
- {
- public A()
- {
- PrintFields();
- }
- public virtual void PrintFields() { }
- }
- class B:A
- {
- int x =1 ;
- int y;
- public B()
- {
- y=-1;
-
- }
- public override void PrintFields()
- {
- Console.WriteLine(x+","+y);
- }
- }
- }
复制代码 输出结果是什么 ?为什么? |