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

C# Equivalent to C++ std::map

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

C++ C#
#include <string>
#include <map>

void Map()
{
    std::map<std::wstring, int> map;
    std::wstring s = L"test";
    map.insert(std::make_pair(s, 1));
    int i = map[s];
    i = map.size();
    bool b = map.empty();
    map.erase(s);
}
using System.Collections.Generic;

void Map()
{
    SortedDictionary<string, int> map = new SortedDictionary<string, int>();
    string s = "test";
    map.Add(s, 1);
    int i = map[s];
    i = map.Count;
    bool b = map.Count == 0;
    map.Remove(s);
}


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

Additional resource: C++ and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.