Proprietà o membro di tipo anonimo '<propertyname>' già dichiarato

Un nome di proprietà può essere definito una sola volta nella dichiarazione di un tipo anonimo. Ad esempio, le dichiarazioni seguenti non sono valide:

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

ID errore: BC36547

Per correggere l'errore

  • Scegliere un nome diverso per una delle proprietà.
' Valid.  
Dim anonType3 = New With {.Name = "Debra Garcia", .Label = .Name & ", President"}  
  • Fornire nuovi nomi per le variabili o le proprietà da cui si deducono i nomi e i valori.
' Valid.  
Dim anonType4 = New With {Key .ProductName = product.Name, Key .CarName = car1.Name}  

Vedi anche