我不确定在字典声明中访问类的属性所需的语法。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
所以,如果我想测试和使用MsgBox()
我怎么涓滴在food > cheese1 > info > attributes2 > name
拉,说,name
?
编辑: 我刚刚意识到Array
在info
需要是词典的关联数组,所以请忽略错误,只是假设它是一个词典这个问题的缘故。
这有一些非常糟糕的代码气味。你不会在任何地方访问类属性(属性),只是字典键和值。这是你的意图吗? – 2012-03-26 15:19:06