Compilerfehler CS0215

Aktualisiert: November 2007

Fehlermeldung

Der Rückgabetyp des True- oder False-Operators muss boolean sein.
The return type of operator True or False must be bool

Benutzerdefinierte true-Operatoren und false-Operatoren müssen den Rückgabetyp bool aufweisen. Weitere Informationen finden Sie unter Überladbare Operatoren (C#-Programmierhandbuch).

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