HiQQD70359 发表于 2016-7-28 13:45:39

抽象方法

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

namespace 抽象方法
{
    class Program
    {
      abstract class ShapesClass       //定义一个抽线类,类名:ShapesClass
      {
            abstract public int Area();//抽象类里面定义一个抽线方法 方法名:Area
      }


      class Square : ShapesClass       //继承抽象方法
      {
            public Square()            //空构造函数
            { }
            int side = 11;
            public Square(int n)         //定义一个方法Square(参数)
            {
                side = n;
            }
            //地区是需要避免的方法
            //编译时错误。
            public override int Area()//重写抽象类 Area
            {
                return side * side;
            }
            interface I                   //接口I
            {
                void M();
            }
            abstract class C : I          //抽象类C继承接口I
            {
                public abstract void M(); //抽象方法继承接口I
            }
      }


      static void Main(string[] args)
      {
            Square sq = new Square();   //实例化
            Console.WriteLine("Area of the square = {0}", sq.Area());//输出值,参数
            Console.ReadKey();//结束
      }
    }
}


ibcadmin 发表于 2016-7-29 09:23:38

1111

Amy尾巴 发表于 2016-7-29 09:32:41

222

剑弑 发表于 2016-8-10 14:52:41

333
页: [1]
查看完整版本: 抽象方法