Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

  • Trusted for over 12 Years
  • Saves Valuable Time
  • Accurate and Reliable
  • Responsive Support

C# Equivalent to C++ std::unordered_map

The nearly exact C# equivalent to the C++ std::unordered_map collection is the .NET Dictionary collection.

Original C++:

#include <string>
#include <unordered_map>

void UnorderedMap()
    std::unordered_map<std::wstring, int> myDictionary;
    std::wstring s = L"test";
    myDictionary.insert(std::make_pair(s, 1));
    int i = myDictionary[s];
    i = myDictionary.size();
    bool b = myDictionary.empty();

Equivalent C#:

void UnorderedMap()
    Dictionary<string, int> myDictionary = new Dictionary<string, int>();
    string s = "test";
    myDictionary.Add(s, 1);
    int i = myDictionary[s];
    i = myDictionary.Count;
    bool b = myDictionary.Count == 0;

If you need to convert from C++ to C# and you are depending on the results being reliable and accurate, then you will want to have C++ to C# Converter, the best C++ to C# converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.