我想静态定义一个映射的字符串数组,如:
var dict = {cat:50, bat:10, rat:30};
并在其中查找值,如:
MessageBox.Show( dict["cat"] )
答案 0 :(得分:6)
Dim dict As New Dictionary(Of String, Integer)()
With dict
.Add("Cat", 50)
.Add("Bat", 10)
.Add("Rat", 30)
End With
答案 1 :(得分:5)
在.NET 4.0中:
Dim d As Dictionary(Of String, Integer) From
{{"cat", 50}, {"bat", 10}, {"rat",30 }}