Compilerfehler CS0215

Der Rückgabetyp des True- oder False-Operators muss boolesch sein.

Benutzerdefinierte true - und false -Operatoren müssen den Rückgabetyp boolaufweisen.

Im folgenden Beispiel wird CS0215 generiert:

// 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()  
   {  
   }  
}