更新:2007 年 11 月
错误消息
方法“name”具有不在第一个参数上的参数修饰符“this”。
this 修饰符只能位于方法的第一个参数上,这向编译器表明该方法是扩展方法。
更正此错误
- 从该方法的除第一个参数之外的其他所有参数中移除 this 修饰符。
示例
下面的代码生成 CS1100,因为 this 参数修饰的是第二个参数:
// cs1100.cs
static class Test
{
static void ExtMethod(int i, this Test c) // CS1100
{
}
}