属性名在匿名类型的声明中只能建立一次。 例如,下面的声明无效:
'' Not valid, because the Label property is assigned to twice.
' Dim anonType1 = New With {.Label = "Debra Garcia", .Label = .Label & ", President"}
'' Not valid, because the property name inferred for both properties is
'' Name.
' Dim anonType2 = New With {Key product.Name, Key car1.Name}
错误 ID: BC36547
更正此错误
- 为其中一个属性选择其他名称。
' Valid.
Dim anonType3 = New With {.Name = "Debra Garcia", .Label = .Name & ", President"}
- 为你将从中推断名称和值的变量或属性提供新名称。
' Valid.
Dim anonType4 = New With {Key .ProductName = product.Name, Key .CarName = car1.Name}