當前位置:成語大全網 - 書法字典 - 如何使用字典的排序方式

如何使用字典的排序方式

字典dic1 =新字典();

dic1。Add("ddd "," 123 ");

dic1。Add("aaa "," 123 ");

dic1。Add("ccc "," 123 ");

dic1。Add("fff "," 123 ");

dic1。Add("eee "," 123 ");

dic1。Add("bbb "," 123 ");

字典dic1Asc = dic1。order by(o = & gt;o.Key)。ToDictionary(o = & gt;o.Key,p = & gtp . Value);

字典dic1desc = dic1。order by descending(o = & gt;o.Key)。ToDictionary(o = & gt;o.Key,p = & gtp . Value);