声明我不想传递的参数

Win*_*-10 1 c# asp.net asp.net-mvc

 public Jquery Extra(this HtmlHelper htmlhelper, 
                     string message, 
                     IDictionary<string, object> htmlAttributes)
Run Code Online (Sandbox Code Playgroud)

如果我在声明我的方法时声明这个Htmlhelper htmlhelper,但我不想在调用方法时传递该参数?

我有意义吗?

P.B*_*key 6

我相信你正在尝试编写扩展方法.你这样定义它

namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static Jquery Extra(this HtmlHelper htmlhelper, string message, IDictionary htmlAttributes)
        {
            //do work
            return Jquery;
        }
    }   
}
Run Code Online (Sandbox Code Playgroud)

然后像这样使用它:

HtmlHelper helper = new HtmlHelper();
Jquery jq = helper.Extra(message, htmlAttributes);
Run Code Online (Sandbox Code Playgroud)