int[] Pattern3 = new int[] {
3,7, 8, 11, 15, 23, 24 };int[] Pattern4 = new int[] {
4,5, 6, 7, 8, 9, 10, 11, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; private void button1_Click(object sender, EventArgs e)
{
Dictionary<int,int[]> dict = new Dictionary<int,int[]>(); dict.Add(3, Pattern3);
dict.Add(4, Pattern4); var d = dict[3].ToList().Except(dict[4]).ToList(); foreach (var item in d)
{
Console.WriteLine(item);
}
}如果是多个dict怎么比较比较好 dict.Add(5, Pattern5);
dict.Add(6, Pattern6);
。。
3,7, 8, 11, 15, 23, 24 };int[] Pattern4 = new int[] {
4,5, 6, 7, 8, 9, 10, 11, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; private void button1_Click(object sender, EventArgs e)
{
Dictionary<int,int[]> dict = new Dictionary<int,int[]>(); dict.Add(3, Pattern3);
dict.Add(4, Pattern4); var d = dict[3].ToList().Except(dict[4]).ToList(); foreach (var item in d)
{
Console.WriteLine(item);
}
}如果是多个dict怎么比较比较好 dict.Add(5, Pattern5);
dict.Add(6, Pattern6);
。。
解决方案 »
- csexwb无法访问新浪微博weibo.com?
- C#里如何实现在messagbox中加入文本框?
- 请教各位,用C#如何做电子书,或制做一个电子书生成工具?
- 我个人感觉VS这个系列里面报表设计器太弱了,大家是如何解决这个问题的。
- 用C#实现FTP,在客户端将大文件上传到服务器,怎样才能断点继续上传(请给个例码)?????
- 对于C#有些迷茫,求高手给与肯定的说明!!!
- 请问任何把一个菜单拷贝到另一个菜单
- 你好:请问在Vs的IDE中如何插入常用语句的啊,它里面有没有一个模板啊,像UltraEdit一样,可以自己定义呢?
- help?
- new 和override 到底有什么区别啊 ,初学者感谢你们
- c#如何操作usb摄像头并实现实时录制MP4格式文件
- 读取XML,出现“根级别上的数据无效”,请帮忙
{
IEnumerable<int> expectedList = null; var keys = robot.DictPattern.Keys.ToList(); for (int i = 0; i < keys.Count; i++)
{
if (keys.Count == 2)
{ return expectedList = robot.DictPattern[keys[i]].Except(robot.DictPattern[keys[i + 1]]);
}
else
{
expectedList = robot.DictPattern[keys[i]].Except(expectedList);
}
} return expectedList;
}
int[] Pattern3 = new int[] {
3,7, 8, 11, 15, 23, 24 }; int[] Pattern4 = new int[] {
4,5, 6, 7, 8, 9, 10, 11, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; int[] Pattern5 = new int[] {
4,5, 6, 7, 8, 9, 10, 11, 12}; int[] Pattern6 = new int[] {
34,35, 36, 37, 38, 39};
var dict = new int[][] { Pattern3, Pattern4, Pattern5, Pattern6 }; var res = dict.Aggregate((x, y) => x.Except(y).ToArray<int>()); //取Pattern3,Pattern4,Pattern5,Pattern6的差集
Dictionary<int, int[]> dict = new Dictionary<int, int[]>();
dict.Add(3, Pattern3);
dict.Add(4, Pattern4);
dict.Add(5, Pattern5);
dict.Add(6, Pattern6);
//取Pattern3,Pattern4,Pattern5,Pattern6的差集
var res = dict.Aggregate((x, y) => { y.Value= x.Value.Except(y.Value).ToArray<int>(); return y; });
//取Pattern3,Pattern4,Pattern5,Pattern6的差集
var res = dict.Aggregate((x, y) => { return new KeyValuePair<int, int[]>(y.Key, x.Value.Except(y.Value).ToArray()); }).Value;
key为6,value为{3,15}的数组,
虽然每个6,{3,15}都是对的,但感觉总是怪怪的