Type characters cannot be used in anonymous type declarations
You cannot use a type character on a property name when you declare an instance of an anonymous type. The data type of the property is inferred from the value assigned to it. For example, the following declarations are not valid.
'' Not valid.
'Dim anon1 = New With {.ID$ = "abc"}
'Dim anon2 = New With {.ID$ = 42}
Error ID: BC36560
To correct this error
Remove the type character from the initializer list. You can explicitly convert the assigned value if this is necessary to establish the data type you want for the property.
' Valid. Dim anon1 = New With {.ID = "abc"} Dim anon2 = New With {.ID = CStr(42)}
See Also
Tasks
How to: Infer Property Names and Types in Anonymous Type Declarations