更新:2007 年 11 月
错误消息
不要使用“System.Runtime.CompilerServices.ExtensionAttribute”。请改用“this”关键字。当在包含扩展方法的非静态类上使用
在 C# 中,必须在静态类中定义扩展方法,并用 this 关键字修饰该方法的第一个参数。任何情况下都不要在源代码中使用该属性。有关更多信息,请参见
更正此错误
移除该属性,然后将 this 修饰符应用于该方法的第一个参数。
示例
下面的示例生成 CS1112:
复制代码 | |
---|---|
// cs1112.cs [System.Runtime.CompilerServices.ExtensionAttribute] // CS1112 public class Extensions { public bool A(bool b) { return b; } } class A { } |