辞書宣言内のクラスの属性にアクセスするために必要な構文が不明です。VB.NETで辞書のクラス変数にアクセスする
Public food As New Dictionary(Of String, cheese) From
{
{"cheese1", New cheese},
{"cheese2", New cheese},
{"cheese3", New cheese}
}
Public Class cheese
Public info As New Dictionary(Of String, Array) From
{
{"attributes1",
{New Dictionary(Of String, String) From
{
{"name", "test"},
{"taste", vbNullString},
{"color", vbNullString}
}
}
},
{"attributes2",
{New Dictionary(Of String, String) From
{
{"name", "test"},
{"taste", vbNullString},
{"color", vbNullString}
}
}
}
}
End Class
だから私はそれをテストし、私はfood > cheese1 > info > attributes2 > name
で、たとえば、name
を引っ張ってトリクルダウンどうやっMsgBox()
を使用したい場合は?
編集:私はちょうどArray
info
でのニーズが連想配列のための辞書をすることに気づい ので、そのエラーを無視してください、ちょうどそれがこの質問のために辞書であると仮定します。
これはコードの匂いが非常に悪いです。どこでもクラスの属性(プロパティ)にアクセスするのではなく、辞書のキーと値だけにアクセスします。それはあなたの意図ですか? –