sortlist的超难度问题 我有一个sortedlist对象,键值分别是1 one 2 two 3 three 现在想在1和2之间插入键值为2 two.one,使之变为1 one 2 two.one 3 two 4 three,请问如何实现。还有如果更改其中的键值? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int pos=1;//定义位置 Dictionary<int, string> sortedlist = new Dictionary<int, string>() { {1,"one"}, {2,"two"}, {3,"three"} }; Dictionary<int, string> sortedlist1 = sortedlist.Take(pos).ToDictionary(c=>c.Key,c=>c.Value); sortedlist1.Add(2,"two.one"); Dictionary<int, string> sortedlist2 = sortedlist.Skip(pos).ToDictionary(c => c.Key+1, c => c.Value); Dictionary<int, string> resultlist = sortedlist1.Concat(sortedlist2).ToDictionary(c => c.Key, c => c.Value); /* * + [0] {[1, one]} System.Collections.Generic.KeyValuePair<int,string> + [1] {[2, two.one]} System.Collections.Generic.KeyValuePair<int,string> + [2] {[3, two]} System.Collections.Generic.KeyValuePair<int,string> + [3] {[4, three]} System.Collections.Generic.KeyValuePair<int,string> */ 我下载了90的试用版,但是不知如何修改iso文件中的setup.sdb? 求助各位大虾们~~ XML配置文件的问题 金质打印通中是如何控制excel边框的 邮件正文解码的问题,高手帮帮忙 listview不显示列标题,该怎么设置?部分代码如下 请教一个线程监控的问题 C#调用vc6生成的dll 难题:C#写文件时,能否仅对文件中的某一行数据就写重写 怎样获取文件的属性?? |javamy| 想法WPF,麻烦大家提供一下有哪些比较好的整套的视频 谢谢 DotNetBar.Bar控件停靠栏点击关闭后,如何用代码实现在显示出来?
Dictionary<int, string> sortedlist = new Dictionary<int, string>() {
{1,"one"},
{2,"two"},
{3,"three"}
};
Dictionary<int, string> sortedlist1 = sortedlist.Take(pos).ToDictionary(c=>c.Key,c=>c.Value);
sortedlist1.Add(2,"two.one");
Dictionary<int, string> sortedlist2 = sortedlist.Skip(pos).ToDictionary(c => c.Key+1, c => c.Value);
Dictionary<int, string> resultlist = sortedlist1.Concat(sortedlist2).ToDictionary(c => c.Key, c => c.Value);
/*
* + [0] {[1, one]} System.Collections.Generic.KeyValuePair<int,string>
+ [1] {[2, two.one]} System.Collections.Generic.KeyValuePair<int,string>
+ [2] {[3, two]} System.Collections.Generic.KeyValuePair<int,string>
+ [3] {[4, three]} System.Collections.Generic.KeyValuePair<int,string> */