【发布时间】:2014-01-27 15:34:29
【问题描述】:
假设我有一个词汇
public Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>();
键 - 1, ..., n
现在我想删除假设第 5 个元素,但想保持正常计数。
有 1, 2, 3, 4, 5, 6, 7, 8, 9.... 而不是 1, 2, 4, 6, 7, 8, 9, ....
怎么做?
【问题讨论】:
-
你不能只用一个列表来代替吗?索引将“保持正常计数”
-
在这里使用
Dictionary并不是很好,因为它不会阻止任何订单。你应该看看SortedList<T> -
我自己传递索引。
-
当然可以,但我需要自己传递密钥
标签: c# loops dictionary iterator