共用方式為


編譯器錯誤 CS1678

更新:2007 年 11 月

錯誤訊息

參數 'number' 宣告為型別 'type1',但應該是 'type2'

當匿名方法中的參數型別與方法所轉型的委派宣告不同時,便會發生這個錯誤。

下列範例會產生 CS1678:

// CS1678
delegate void D(int i);
class Errors 
{
   static void Main() 
   {
      D d = delegate(string s) { };   // CS1678
      // To resolve, use the following line instead:
      // D d = delegate(int s) { };
   }
}