我的意思是这样的(粗体):
Dim anonType = New {{.Property1 = 10,.Property2 As Decimal? = Nothing}
答案 0 :(得分:0)
你可以随时解决这个问题..
Private Sub test()
Dim tempDecimal? As Decimal = Nothing
Dim anonType = New With {.Property1 = 10, .Property2 = tempDecimal}
' property value is nothing here, but if tempDecimal isnt declared as nullable,
'the value will be 0
anonType.property2 = Nothing
anonType.property2 = 5
'tp will be Decimal here
Dim tp As Type = anonType.property2.GetType
End Sub