c# - C#中哈希表的操作

标签 c# .net hashtable

使用 Hashtable 我想将多个对象映射到同一个键。例如。键是“年龄”,值是结构“学生”的对象。

我想在感知上会有一种链表,其中 Key 充当“头部” 25->obj1->obj2->obj3

这是我的问题:

Is the above representation correct? If not, which data structure can be used for achieving the same?

Can I look up for a specific field on the above data representation. e.g. One I reach the key 25, I look for the name 'Scott' in the row. Will I be able to stop/ get a pointer to the object containing the field Scott?

谢谢!

最佳答案

如果您使用的是 C#,最好的选择可能是(本质上,这就是您所提议的):

var collection = new Dictionary<Age, List<Student>>();

假设 Age 和 Student 都是类型。

关于c# - C#中哈希表的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3441503/

相关文章:

c# - 在 C++ 中使用 C# dll 时出现 C2380 错误

c++ - 如何从 .NET 代码中使用 Activator 调用的 COM 库打印到控制台?

.net - 使用 AJAX 为 Post WebMethod 更正 Web.Config

java - 我的 HashMap 应该有多大?

java - Java 中的哈希表内存使用情况

c++ - 使用 C++ 将哈希表复制到另一个哈希表

c# - 如何在 Asp.Net 中间件中抛出错误

c# - IdentityServer4 直接链接到 Facebook 身份验证

c# - 从外部 MVC 应用程序中的 CrmOrganizationServiceContext 获取 OrganizationServiceProxy

c# - 是否可以通过一个连接在 .Net 中实现异步 Web 服务调用?