Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You cannot infer an anonymous type member name from a complex expression.
Dim numbers() As Integer = {1, 2, 3, 4, 5}
' Not valid.
' Dim instanceName1 = New With {numbers(3)}
For more information about sources from which anonymous types can and cannot infer member names and types, see How to: Infer Property Names and Types in Anonymous Type Declarations.
Error ID: BC36556
To correct this error
Assign the expression to a member name, as shown in the following code:
Dim instanceName2 = New With {.number = numbers(3)}
See Also
Tasks
How to: Infer Property Names and Types in Anonymous Type Declarations