Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0216

The operator 'operator' requires a matching operator 'missing_operator' to also be defined

A user-defined true operator requires a user-defined false operator, and vice versa.

The following sample generates CS0216:

// CS0216.cs
class MyClass
{
   public static bool operator true (MyClass MyInt)   // CS0216
   {
      return true;
   }

   // to resolve, uncomment the following operator definition
   /*
   public static bool operator false (MyClass MyInt)
   {
      return true;
   }
   */

   public static void Main()
   {
   }
}
Show:
© 2014 Microsoft