c# 接口相同方法申明使用

using System;


namespace ConsoleApp1
{
   
    interface IInterface1
    {
        void ft();
    }
    interface IInterface2
    {
        void ft();
    }
    class MyClass : IInterface1, IInterface2
    {
         void IInterface1.ft()
        {
            Console.WriteLine("1");
        }
         void IInterface2.ft()
        {
            Console.WriteLine("2");
        }
    }

    class Program
    {

        static void Main(string[] args)
        {
            MyClass myClass = new MyClass();

            IInterface1 interface1 = myClass;
            IInterface2 interface2 = myClass;

            interface1.ft();
            interface2.ft();
        }
    }
}

 

posted @ 2018-12-08 23:00  紅人  阅读(572)  评论(0编辑  收藏  举报