接口的使用

static void Main(string[] args)
        {
            var k = new Test() { ID = 1, Age = 15 };
            T1 a = k;
            T2 b = k;
            a.show();
            //Console.WriteLine(b.Age);
            b.show();
        }
    }
    class Test:T1,T2
    {
        public int ID { get; set; }
        public int Age { get; set; }
        public void show()
        {
            Console.WriteLine(ID);
        }
    }
    interface T1
    {
        public int ID { get; set; }
        public void show();
    }
    interface T2
    {
        public int Age { get; set; }
        public void show();
    }

 

posted @ 2021-04-20 21:21  南秦岭  阅读(37)  评论(0编辑  收藏  举报