什么是C#相当于< map>在C ++中? [英] What is C# equivalent of <map> in C++?

查看:101
本文介绍了什么是C#相当于< map>在C ++中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了一个myComplex类。我需要将其映射到整数。在C ++中,我将创建一个地图为
map< myComplex,int> first;



在C#中做这样的事情?

解决方案

相当于class 系统中的SortedDictionary< TKey,TValue> .Collections.Generic 命名空间。



如果你不关心类 > System.Collections.Generic 命名空间可能就足够了。


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#?

解决方案

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.

这篇关于什么是C#相当于&lt; map&gt;在C ++中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆