Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于Html帮助程序的Visual Studio自动完成_C#_Visual Studio_Razor_Intellisense - Fatal编程技术网

C# 用于Html帮助程序的Visual Studio自动完成

C# 用于Html帮助程序的Visual Studio自动完成,c#,visual-studio,razor,intellisense,C#,Visual Studio,Razor,Intellisense,在Razor中编写Html帮助器元素时,例如: @Html.LabelFor(m => m.MyProperty, new { @class="col-sm-2 control-label" }) 或 Visual studio正在将“新{”转换为“新对象{”,但这是无效的。intellisense为什么要这样做?我是否遗漏了一些内容?我想这是因为特定的重载签名: public static MvcHtmlString TextBoxFor<TModel, TProperty>

在Razor中编写Html帮助器元素时,例如:

@Html.LabelFor(m => m.MyProperty, new { @class="col-sm-2 control-label" })

Visual studio正在将“新{”转换为“新对象{”,但这是无效的。intellisense为什么要这样做?我是否遗漏了一些内容?

我想这是因为特定的重载签名:

public static MvcHtmlString TextBoxFor<TModel, TProperty>(
    this HtmlHelper<TModel> htmlHelper,
    Expression<Func<TModel, TProperty>> expression,
    Object htmlAttributes
)
公共静态MvcHtmlString TextBoxFor( 这个HtmlHelper HtmlHelper, 表情表情, 对象属性 ) 毕竟,
htmlAttributes
必须有某种类型的声明,而
Object
是他们选择的最低公分母,因为在最初编写这些方法时,
dynamic
不可用


当然,这有点烦人——但Intellisense只是在做它的工作:)

它对我也一样。我只是删除了
对象
部分,继续我的一天。
public static MvcHtmlString TextBoxFor<TModel, TProperty>(
    this HtmlHelper<TModel> htmlHelper,
    Expression<Func<TModel, TProperty>> expression,
    Object htmlAttributes
)