下面回答非常准确。

https://stackoverflow.com/questions/13089496/why-i-cant-call-dbcontext-objectcontext-directly

进而,我们又了解到显示接口实现的一些细节。接口必须被实现,不管你怎样实现的,比如通过显示定义,或者继承其他的类而来的接口实现都可以。

 

public interface IA
    {
        void Show();
    }

    public interface IB
    {
        void Show();
    }

    public abstract class AB
    {
        public abstract void Show1();
    }

    public class D : AB, IA, IB
    {
        public void Show()
        {
            Console.WriteLine("concrete show");
        }

        void IA.Show()
        {
            Console.WriteLine("implement IA");
        }

        void IB.Show()
        {
            Console.WriteLine("implement IB");
        }

        public override void Show1()
        {
            Console.WriteLine("D implement AB class");
        }
    }

var d = new D();
            d.Show();

            ((IA)d).Show();

            ((IB)d).Show();

 

相关文章:

  • 2022-12-23
  • 2022-01-25
  • 2022-03-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2020-04-07
  • 2021-06-04
相关资源
相似解决方案