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