共用方式為


編譯器錯誤 CS1110

更新:2007 年 11 月

錯誤訊息

未參考 System.Core.dll,因此無法在方法宣告的第一個參數上使用 'this' 修飾詞。請加入 System.Core.dll 的參考,或移除方法宣告中的 'this' 修飾詞。

.NET Framework 3.5 (含) 以後版本不支援擴充方法。擴充方法會產生以屬性 (Attribute) 標記方法的中繼資料 (Metadata)。這個屬性類別 (Class) 是在 system.core.dll 中。

若要更正這個錯誤

  • 如訊息所述,加入 System.Core.dll 的參考,或移除方法宣告中的 this 修飾詞 (Modifier)。

範例

如果不是使用 System.Core.dll 的參考編譯檔案,下列範例便會產生 CS1110:

// cs1110.cs
// CS1110
// Compile with: /target:library
public static class Extensions
{
    public static bool Test(this bool b) { return b; }
}

請參閱

參考

擴充方法 (C# 程式設計手冊)