首页 > 其他 > 详细

接口 Interface

时间:2017-04-02 21:44:16      阅读:77      评论:0      收藏:0      [点我收藏+]

interface 关键字 声明接口

接口中的成员默认都是public

能力不一样的时候适合用接口

技术分享
using System;
using System.Collections;
using System.Collections.Generic;
namespace Dome
{
    class dom
    {
        static void Main(string[] args)
        {
            play iplay = new student();
            iplay.iplay();
            Console.WriteLine();
            Console.ReadKey();
        }
    }
    public class person {//父类
        public void sayhello() { Console.WriteLine("我是人类"); }
    }
    public class student:person,play {//继承父类person和接口play  必须实现接口中的成员
        public void hello() { Console.WriteLine("我是学生"); }
        public void iplay() { Console.WriteLine("实现接口"); }
    }
    interface play {//接口中的成员默认是public
        void iplay();
    }
}
 
View Code

 

接口 Interface

原文:http://www.cnblogs.com/syzly/p/6659904.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!