VB中匿名类型的语法是什么?

mar*_*c.d 1 vb.net syntax anonymous-types

我试图设置htmlAttribute属性,但我无法弄清楚正确的语法

这是它在c#中的工作原理

<%=Html.Password("myPassword", 50,"",new { style = "width:100px" })%><br />
Run Code Online (Sandbox Code Playgroud)

什么是vb.net版本的

new { style = "width:100px" }
Run Code Online (Sandbox Code Playgroud)

Mic*_*cah 6

VB中内联匿名类型的正确语法是:

New With { .Style = "width:100px" }
Run Code Online (Sandbox Code Playgroud)

如果要声明匿名类型,请使用以下语法:

Dim myVariable = New With { .Style = "width:100px" }
Run Code Online (Sandbox Code Playgroud)