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

C++ Equivalent to VB Collection Initializers

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

VB.NET C++
'List:
Dim myList As New List(Of Integer)() From {1, 2, 3}

'Dictionary:
Dim myD As New Dictionary(Of String, Integer) From {
    {string1, 80},
    {string2, 85}
}
//vector:
std::vector<int> myList = {1, 2, 3};

//unordered_map:
std::unordered_map<std::wstring, int> myD = {
    {string1, 80},
    {string2, 85}
};


Use VB to C++ Converter to convert from VB to C++.     

Additional resource: VB.NET and C++ Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.