• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C# Equivalent to C++ std::unordered_map

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

C++ C#
#include <string>
#include <unordered_map>

void UnorderedMap()
    std::unordered_map<std::wstring, int> map;
    std::wstring s = L"test";
    map.emplace(s, 1);
    int i = map[s];
    i = map.size();
    bool b = map.empty();
using System.Collections.Generic;

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

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

Additional resource: C++ and C# Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.