C# 接口的案例

using System;
namespace 接口
{
    internal class Program:IMyInterface
    {
        string id = "";
        string name = "";
        public string ID { get { return id; } set { id = value; } }
        public string Name { get { return name; } set { name = value; } }

        static void Main(string[] args)
        {
           Program program = new Program(); 
            IMyInterface myInterface =program;
            program.ID = "TM";
            program.Name = "C# 3.5从入门到应用开发";
            myInterface.Showinfo();

            Console.ReadKey();
        }

        public void Showinfo()
        {
            Console.WriteLine("编号\t 姓名");
            Console.WriteLine(ID + "\t" + name);
        }
    }
    interface IMyInterface
    { 
        string ID { get; set; }
        string Name { get; set; }
        void Showinfo();
    }
}

上一篇:正则表达式


下一篇:在 Android 手机上使用 Terminal IDE 远程登录你的 Mac/Ubuntu