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

后端 未结 7 741
谎友^
谎友^ 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();
       }
    }
    

提交回复
热议问题