Dictionary中元素的顺序我的问题是关于枚举字典元素// Dictionary definitionprivate Dictionary<string, string> _Dictionary = new Dictionary<string, string>();// add values using add_Dictionary.Add("orange", "1");_Dictionary.Add("apple", "4");_Dictionary.Add("cucumber", "6");// add values using []_Dictionary["banana"] = 7;_Dictionary["pineapple"] = 7;// Now lets see how elements are returned by IEnumeratorforeach (KeyValuePair<string, string> kvp in _Dictionary){ Trace.Write(String.Format("{0}={1}", kvp.Key, kvp.Value));}枚举的元素将以什么顺序排列?我可以强制命令按字母顺序排列吗?
- 3 回答
- 0 关注
- 687 浏览
添加回答
举报
0/150
提交
取消