編譯器錯誤 CS0564
更新:2007 年 11 月
錯誤訊息
多載移位 (Shift) 運算子的第一個運算元的型別必須具有與包含型別 (Containing Type) 相同的型別,而且第二個運算元的型別必須是 int
您嘗試以不正確型別的運算元來多載移位運算子 (<< 或 >>)。第一個運算元必須是包含型別,而第二個運算元必須屬於 int 型別。
下列範例會產生 CS0564:
// CS0564.cs
using System;
class C
{
public static int operator << (C c1, C c2) // CS0564
// To correct, change second operand to int, like so:
// public static int operator << (C c1, int c2)
{
return 0;
}
static void Main()
{
}
}