为什么New <type> With {}有效但New With {}没有?</type>

时间:2013-03-27 03:07:57

标签: vb.net asp.net-mvc-4 anonymous-types razor-2

我总是使用New With {}而没有任何问题。为什么会有所不同?

Razor VB.NET代码

Using Ajax.BeginForm(New AjaxOptions With {.HttpMethod = "Post"})
    @* no problem *@
End Using
Using Ajax.BeginForm(New With {.HttpMethod = "Post"})
    @* Value of type '<anonymous type>' cannot be converted to 'System.Web.Mvc.Ajax.AjaxOptions'. *@
End Using

1 个答案:

答案 0 :(得分:1)

anonymous typeNew With {})不会延伸/继承AjaxOptions - 符合AjaxOptions的对象必需 {{1 }}