今天很容易,我想。在C#中,它的:
@H_301_1@Dictionary<String,String> dict = new Dictionary<string,string>() { { "","" } };
但在vb中,以下不工作。
@H_301_1@Public dict As Dictionary(Of String,String) = New Dictionary(Of String,String) (("",""))我很肯定有一种方法来添加他们在声明,但我不知道如何。是的,我想在声明中添加他们,而不是任何其他时间。 :)所以希望这是可能的。感谢大家。
我也试过:
@H_301_1@Public dict As Dictionary(Of String,String) ({"",""})和…
@H_301_1@Public dict As Dictionary(Of String,String) {("","")}和…
@H_301_1@Public dict As Dictionary(Of String,String) {{"",""}}
这是可能在VB.NET 10:
@H_301_1@Dim dict = New Dictionary(Of Integer,String) From {{ 1,"Test1" },{ 2,"Test1" }}
原文链接:https://www.f2er.com/vb/256349.html不幸的是IIRC VS 2008使用VB.NET 9编译器不支持这种语法。
对于那些可能感兴趣的是在幕后发生的事情(C#):
@H_301_1@Dictionary<int,string> VB$t_ref$S0 = new Dictionary<int,string>(); VB$t_ref$S0.Add(1,"Test1"); VB$t_ref$S0.Add(2,"Test1"); Dictionary<int,string> dict = VB$t_ref$S0;