How to sort NameValueCollection using a key in C#?
问题 I've written following code and it works too - but I wanted to know whether their is better way than this : NameValueCollection optionInfoList = ..... ; if (aSorting) { optionInfoListSorted = new nameValueCollection(); String[] sortedKeys = optionInfoList.AllKeys; Array.Sort(sortedKeys); foreach (String key in sortedKeys) optionInfoListSorted.Add(key, optionInfoList[key]); return optionInfoListSorted; } 回答1: Use a SortedDictionary instead. 回答2: Perhaps you could use a different kind of list,