How to insert values into VB.NET Dictionary on instantiation?
问题 Is there a way that I can insert values into a VB.NET Dictionary when I create it? I can, but don't want to, do dict.Add(int, "string") for each item. Basically, I want to do "How to insert values into C# Dictionary on instantiation?" with VB.NET. var dictionary = new Dictionary<int, string> { {0, "string"}, {1, "string2"}, {2, "string3"} }; 回答1: If using Visual Studio 2010 or later you should use the FROM keyword like this: Dim days = New Dictionary(Of Integer, String) From {{0, "string"},