如何在VB.NET中直接填写字典(TKey,TValue)
在VB.NET中有没有同样的方法如何在VB.NET中直接填写字典(TKey,TValue),vb.net,Vb.net,在VB.NET中有没有同样的方法 Dictionary<int, string> myDict = new Dictionary<int, string>() { { 2, "This" }, { 1, "is" }, { 5, "radio" }, { 12, "clash" }, }; Dictionary myDict=newdictionary()
Dictionary<int, string> myDict = new Dictionary<int, string>()
{
{ 2, "This" },
{ 1, "is" },
{ 5, "radio" },
{ 12, "clash" },
};
Dictionary myDict=newdictionary()
{
{2,“这个”},
{1,“is”},
{5,“无线电”},
{12,“冲突”},
};
如Marcel在上述评论中所述:
Dim myDict As New Dictionary(Of Integer, String) From _
{{1, "one"}, {2, "two"}, {3, "three"}}
同样的问题,请检查jgauffin的答案。下面是一个例子:Dim myDic作为来自{{1,“One”}、{2,“Two”}
的新字典(整数,字符串)。这仅适用于VB.NET 10