Compiler Error CS0215
The return type of operator True or False must be bool
User-defined true and false operators must have a return type of bool.
The following sample generates CS0215:
C#
// 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()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: