What is C# equivalent of <map> in C++?

Abhash Kumar Singh picture Abhash Kumar Singh · Jan 17, 2014 · Viewed 181.6k times · Source

I have defined a class myComplex. I need to map it to integers. In C++ I would have created a map as map<myComplex,int> first;

How to do such thing in C#?

Answer

dalle picture dalle · Jan 17, 2014

The equivalent would be class SortedDictionary<TKey, TValue> in the System.Collections.Generic namespace.

If you don't care about the order the class Dictionary<TKey, TValue> in the System.Collections.Generic namespace would probably be sufficient.