Search code examples
c#inheritanceoverloadingoperator-keywordradix

Is there a way to call base method for overloaded operators? c#


 class x : y
{
   public static bool x operator >(x i1, x i2)
   {
          // **** 
   }
}

Is it possible to call the > from class y in ****? If so, how?


Solution

  • Upcast x to y then you should be able to call y's implementation.

    class x : y
    {
       public static bool x operator >(x i1, x i2)
       {
            bool greater = (y)i1 > (y)i2;
            return whatever;
       }
    }