如何在.NET中创建词典列表? [英] How do I create a List of Dictionaries in .NET?

查看:83
本文介绍了如何在.NET中创建词典列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建Dictionary<string,int>个项目的列表.我不确定如何在列表中添加项目以及如何在遍历列表时取回值.我想在C#中使用它,就像这样:

I am trying to create a List of Dictionary<string,int> items. I am not sure how to add items in list and how to get back the values while traversing the list. I want to use it in C#, like so:

public List<Dictionary<string,int>> MyList= new List<Dictionary<string,int>>();

推荐答案

5年内发生了很多变化...您现在可以执行以下操作:

A lot has changed in 5 years... You can now do the following:

ListDictionary list = new ListDictionary();
list.Add("Hello", "Test1");
list.Add("Hello", "Test2");
list.Add("Hello", "Test3");

享受!

这篇关于如何在.NET中创建词典列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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