2009-01-21 218 views
1

为什么我得到字符串带下划线的错误“Expected class,interface,enum or struct”?MVC帮助器扩展

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

    { 
     return "wtf"; 

    } 

回答

6

你的扩展方法必须是一个静态类内:

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

    } 
} 
+0

该固定一个部件,但它仍然是不注册与system.web.mvc.htmlhelpers的延伸。还有什么需要做的? – zsharp 2009-01-21 21:36:13