【发布时间】:2016-01-21 00:27:45
【问题描述】:
我正在使用包含一个对象和另一个列表的 KeyValuePair 创建以下列表:
var testList = new List<KeyValuePair<classTypeObject, List<DataTypeObject>>>
{
new KeyValuePair<classTypeObject, List<DataTypeObject>>(classTypeObject.Mountain, new List<DataTypeObject>()),
new KeyValuePair<classTypeObject, List<DataTypeObject>>(classTypeObject.City, new List<DataTypeObject>()),
};
如何将项目添加到列表中,例如 Key=classTypeObject.City 的第二个条目?
【问题讨论】:
-
您可以通过索引
testList[1]解决它,除非您正在寻找更通用的解决方案。
标签: c# .net list keyvaluepair