// dic为字典
for (int index = 0; index < dic.Count; index++)
{
var item = dic.ElementAt(index);
var itemKey = item.Key;
var itemValue = item.Value;
}
如果dic没有ElementAt()方法,是因为ElementAt 是一个扩展方法在 System.Linq.Enumerable 中定义。 故using System.Linq;
C#使用下标遍历Dictionary
猜你喜欢
转载自blog.csdn.net/qq_36537768/article/details/104344401
今日推荐
周排行