MVC助手扩展

时间:2009-01-21 21:20:45

标签: asp.net-mvc extension-methods html-helper

为什么我会在下划线的字符串中出现错误“Expected class,interface,enum or struct”?

 public static string IsSelected(this HtmlHelper helper, string A, string B)

    {
         return "wtf";

    }

1 个答案:

答案 0 :(得分:6)

您的扩展方法需要在静态类中:

public static class MyExtensions
{
    public static string IsSelected( this HtmlHelper helper, string A, string B)
    {
        return "wtf";

    }
}