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#?
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#?
On
Take a look at the Dictionary class in System::Collections::Generic.
Dictionary<myComplex, int> myMap = new Dictionary<myComplex, int>();
On
.NET Framework provides many collection classes too. You can use Dictionary in C#. Please find the below msdn link for details and samples http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
On
std::map<Key, Value> → SortedDictionary<TKey, TValue>
std::unordered_map<Key, Value> → Dictionary<TKey, TValue>
The equivalent would be class
SortedDictionary<TKey, TValue>in theSystem.Collections.Genericnamespace.If you don't care about the order the class
Dictionary<TKey, TValue>in theSystem.Collections.Genericnamespace would probably be sufficient.