C# 用于Html帮助程序的Visual Studio自动完成
在Razor中编写Html帮助器元素时,例如: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>
@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
)