編譯器錯誤 CS0215
更新:2007 年 11 月
錯誤訊息
運算子 True 或 False 的傳回型別必須為 bool
使用者定義的 True 和 False 運算子的傳回型別必須為 bool。如需詳細資訊,請參閱可多載的運算子 (C# 程式設計手冊)。
下列範例會產生 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()
{
}
}