閱讀英文

共用方式為


匿名類型成員或屬性 '<propertyname>' 已宣告

屬性名稱只能在匿名類型的宣告中建立一次。 例如,下列宣告無效:

VB
'' 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︰ BC36547

更正這個錯誤

  • 請為其中一個屬性選擇不同的名稱。
VB
' Valid.  
Dim anonType3 = New With {.Name = "Debra Garcia", .Label = .Name & ", President"}  
  • 請為您正在推斷名稱和值的變數或屬性名稱提供新名稱。
VB
' Valid.  
Dim anonType4 = New With {Key .ProductName = product.Name, Key .CarName = car1.Name}  

另請參閱