编译器错误 CS1102
更新:2007 年 11 月
错误消息
参数修饰符“out”不能与“this”一起使用。
在 this 关键字修饰静态方法的第一个参数时,它向编译器指示该方法是扩展方法。不需要或不允许对扩展方法的第一个参数使用任何其他修饰符。
更正此错误
- 从第一个参数移除未经授权的修饰符。
示例
下面的示例生成 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
}