Udostępnij za pośrednictwem


Anonymous type member or property '<propertyname>' is already declared

A property name can be established only once in the declaration of an anonymous type. For example, the following declarations are not valid:

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

Error ID: BC36547

To correct this error

  • Choose a different name for one of the properties.

    ' Valid.
    Dim anonType3 = New With {.Name = "Debra Garcia", .Label = .Name & ", President"}
    
  • Provide new names for the variables or property names from which you are inferring names and values.

    ' Valid.
    Dim anonType4 = New With {Key .ProductName = product.Name, Key .CarName = car1.Name} 
    

See Also

Tasks

How to: Infer Property Names and Types in Anonymous Type Declarations

Concepts

Anonymous Types