This documentation is archived and is not being maintained.

Anonymous type member name can be inferred only from a simple or qualified name with no arguments

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 (Visual Basic).

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)}