[转载]获取2个集合List<T>的共同元素

                List<int> a = new List<int> { 1, 2, 3, 4, 5, 6 };
                List<int> b = new List<int> { 1, 21, 13, 14, 15, 61 };
                List<int> c = a.Intersect(b).ToList();
                foreach (var item in c)
                {
                    Console.WriteLine(item);
                }

posted on 2017-12-29 11:47  New_q  阅读(116)  评论(0编辑  收藏  举报

导航