Rob*_*cks 1 vb.net arrays string dictionary
我想静态定义一个映射的字符串数组,如:
var dict = {cat:50, bat:10, rat:30};
Run Code Online (Sandbox Code Playgroud)
并在其中查找值,如:
MessageBox.Show( dict["cat"] )
Run Code Online (Sandbox Code Playgroud)
Dim dict As New Dictionary(Of String, Integer)()
With dict
.Add("Cat", 50)
.Add("Bat", 10)
.Add("Rat", 30)
End With
Run Code Online (Sandbox Code Playgroud)
在.NET 4.0中:
Dim d As Dictionary(Of String, Integer) From
{{"cat", 50}, {"bat", 10}, {"rat",30 }}
Run Code Online (Sandbox Code Playgroud)