• Saves Valuable Time
  • Trusted Accuracy for 14 Years
  • 15-Day Money-Back Guarantee

VB Equivalent to C# Collection Initializers

In VB, the keyword 'From' is used to initialize collections during construction.

C# VB.NET
//List:
List<int> myList = new List<int>() {1, 2, 3};

//Dictionary:
Dictionary<string, int> myD = new Dictionary<string, int>() {
    {name1, 80},
    {name2, 85}
};
'List:
Dim myList As New List(Of Integer)() From {1, 2, 3}

'Dictionary:
Dim myD As New Dictionary(Of String, Integer) From {
    {name1, 80},
    {name2, 85}
}


Use Instant VB to convert from C# to VB.NET.     

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2018 Tangible Software Solutions, Inc.