复制代码 代码如下:
static void Main(string[] args)
{
int[] a = { 1, 2, 3, 4, 5, 6, 7 };
int[] b = { 4, 5, 6, 7, 8, 9, 10 };
int[] c = { 1, 2, 3, 3, 4, 1, 2, 4, 6, 1, 6, 5 };
// 交集
var fuck = a.Intersect(b);
// 并集
var shit = a.Union(b);
// a有b没有的
var diff1 = a.Except(b);
// b有a没有的
var diff2 = b.Except(a);
var max = a.Max();
var min = a.Min();
var avg = a.Average();
var dis = c.Distinct();
Print(fuck);
Print(shit);
Print(diff1);
Print(diff2);
Console.WriteLine(max);
Console.WriteLine(min);
Console.WriteLine(avg);
Print(dis);
Console.ReadKey();
}
private static void Print(IEnumerable<int> list)
{
foreach (var item in list)
{
Console.Write(item + " ");
}
Console.WriteLine();
}
一些参考:
新闻热点
疑难解答
图片精选