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();
        }
    }
}

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

 

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2021-06-15
  • 2021-11-03
  • 2022-12-23
  • 2021-11-23
  • 2021-07-31
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案