編譯器錯誤 CS1101
更新:2007 年 11 月
錯誤訊息
參數修飾詞 'ref' 不能和 'this' 一起使用。
this 關鍵字修改靜態方法的第一個參數時,會對編譯器 (Compiler) 發出方法為擴充方法的信號。擴充方法的第一個參數不需要也不允許其他任何修飾詞 (Modifier)。
範例
下列範例會產生 CS1101:
// cs1101.cs
// Compile with: /target:library
public static class Extensions
{
// No type parameters.
public static void Test(ref this int i) {} // CS1101
// Single type parameter.
public static void Test<T>(ref this T t) {}// CS1101
// Multiple type parameters.
public static void Test<T,U,V>(ref this U u) {}// CS1101
}