序列结果集比较函数
不解释了,从代码看结果:
string temp1 = "A,B,C,D,E,F,G,H,J,K"; string temp2 = "H,J,K,L,M,N,O,P,Q,R"; Console.WriteLine($"原始 A :{temp1}"); Console.WriteLine($"原始 B :{temp2}"); Console.WriteLine(new string('=',50)); Console.WriteLine("并集:A Union B"); Console.WriteLine(string.Join(",", temp1.Split(',').Union(temp2.Split(',')))); Console.WriteLine(new string('=', 50)); Console.WriteLine("交集:A Intersect B"); Console.WriteLine(string.Join(",", temp1.Split(',').Intersect(temp2.Split(',')))); Console.WriteLine(new string('=', 50)); Console.WriteLine("差集:A Except B"); Console.WriteLine(string.Join(",", temp1.Split(',').Except(temp2.Split(','))));