当前位置:   article > 正文

C#的Dictionary字典集合按照key键进行升序和降序排列_c# dictionary 降序

c# dictionary 降序
  1. //这个是集合
  2. Dictionary<int, string> list = new Dictionary<int, string>();
  3. //升序
  4. Dictionary<int, string> dic_asc = list.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
  5. //降序
  6. Dictionary<int, string> dic_desc = list.OrderByDescending(p => p.Key).ToDictionary(p => p.Key, o => o.Value);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/84503
推荐阅读
  

闽ICP备14008679号