Work with SortedDictionary in C#
Forums:
var dic = new SortedDictionary<int, String>
{ { 3, "three" }, { 1, "one" }, { 2, "two" } };
var str = "";
foreach (var key in dic.Keys) {
var value = dic[key];
str += (str == "" ? "" : ", ") +
string.Format("{{ {0}, \"{1}\" }}", key, value);
}
//str is "{ 1, "one" }, { 2, "two" }, { 3, "three" }"
//sorted by key
- Log in to post comments