开发者

What's the easiest way to get Dictionary functionality in VB.NET?

开发者 https://www.devze.com 2022-12-21 17:08 出处:网络
I want to statically defin开发者_运维问答e a mapped array of strings like: var dict = {cat:50, bat:10, rat:30};

I want to statically defin开发者_运维问答e a mapped array of strings like:

var dict = {cat:50, bat:10, rat:30};

and lookup values within it like:

MessageBox.Show( dict["cat"] )


Dim dict As New Dictionary(Of String, Integer)()

With dict 
    .Add("Cat", 50)
    .Add("Bat", 10)
    .Add("Rat", 30)
End With


In .NET 4.0:

Dim d As Dictionary(Of String, Integer) From
    {{"cat", 50}, {"bat", 10}, {"rat",30 }} 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号