<分区>
Possible Duplicate:
Why is the 'this' keyword required to call an extension method from within the extended class
我想本地化我的 MVC 应用程序然后我想使用 w(message)
方法和作为
“flem”回答了here我有这段代码:
namespace System.Web.WebPages
{
public static class Localization
{
public static string w(this WebPageBase page, string message)
{
return message;
}
}
}
但是在 razor page(page.cshtml
) 我不能使用 @w("hi")
但是 @this.w("hi")
有效。 我想知道为什么 this.method()
有效但 method()
无效?