How to call explicit interface implementation methods internally without explicit casting?

后端 未结 7 713
谎友^
谎友^ 2020-12-08 18:44

If I have

public class AImplementation:IAInterface
{
   void IAInterface.AInterfaceMethod()
   {
   }

   void AnotherMethod()
   {
      ((IAInterface)this)         


        
相关标签:
7条回答
  • 2020-12-08 19:27

    Can't you just remove the "IAInterface." from the method signature?

    public class AImplementation : IAInterface
    {
       public void AInterfaceMethod()
       {
       }
    
       void AnotherMethod()
       {
          this.AInterfaceMethod();
       }
    }
    
    0 讨论(0)
提交回复
热议问题