Compiler Error CS0215
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error CS0215 

Error Message

The return type of operator True or False must be bool

User-defined true and false operators must have a return type of bool. For more information, see Overloadable Operators (C# Programming Guide).

The following sample generates CS0215:

// CS0215.cs
class MyClass
{
   public static int operator true (MyClass MyInt)   // CS0215
   // try the following line instead
   // public static bool operator true (MyClass MyInt)
   {
      return true;
   }

   public static int operator false (MyClass MyInt)   // CS0215
   // try the following line instead
   // public static bool operator false (MyClass MyInt)
   {
      return true;
   }

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