プロパティ名は、匿名型の宣言で 1 回だけ確立できます。 たとえば、次の宣言は無効です。
'' 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
このエラーを解決するには
- プロパティの 1 つには別の名前を選択してください。
' Valid.
Dim anonType3 = New With {.Name = "Debra Garcia", .Label = .Name & ", President"}
- 名前と値を推定している変数またはプロパティに新しい名前を指定します。
' Valid.
Dim anonType4 = New With {Key .ProductName = product.Name, Key .CarName = car1.Name}
関連項目
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET