如何在VB.NET中直接填写Dictionary(Of TKey,TValue)

时间:2010-07-21 13:56:58

标签: vb.net

有没有办法在VB.NET中做同样的事情?

Dictionary<int, string> myDict = new Dictionary<int, string>()     
{        
     { 2, "This" },    
     { 1, "is" },          
     { 5, "radio" },      
     { 12, "clash" },     
};

1 个答案:

答案 0 :(得分:9)

如上面Marcel的评论所述:

Dim myDict As New Dictionary(Of Integer, String) From _
        {{1, "one"}, {2, "two"}, {3, "three"}}