C#面向对象基础--抽象类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace abstractTest
{
    //只要一个方法声明为:abstract,类也必须使用abstract修饰,abstract修饰的类不能实例化
     public abstract class Person
    {
         //声明SayHello抽象方法
        public abstract void SayHello();
    }

     public class Chinese : Person
     {
         //子类必须实现父类的abstract方法
         public override void SayHello()
         {
             //throw new NotImplementedException();
             Console.WriteLine("我是中国人");
         }
     }
    class Program
    {
        static void Main(string[] args)
        {
            Chinese c = new Chinese();
            c.SayHello();
        }
    }
}
posted @ 2012-11-13 16:59  菜鸟程序猿  阅读(176)  评论(0编辑  收藏  举报