interface ILol
{
   void LOL();
}

class Rofl : ILol
{
   void ILol.LOL()
   {
      GlobalLOLHandler.RaiseROFLCOPTER(this);
   }
   public Rofl()
   {
      //Is there shorter way of writing this or i is there "other" problem with implementation??
      (this as ILol).LOL();
   }
}

最佳答案

您已经实现了接口explicitly,通常不需要这样做。相反,只需隐式实现它,然后像调用其他任何方法一样调用它即可:

class Rofl : ILol
{
    public void LOL() { ... }

    public Rofl()
    {
        LOL();
    }
}


(请注意,您的实现也需要公开。)

10-06 13:00