日期:2014-05-17 浏览次数:20874 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<List<string>> data = new List<List<string>>()
{
new List<string>() { "1", "2", "3", "8" },
new List<string>() { "1", "3", "5", "8" },
new List<string>() { "1", "2", "5", "8" },
new List<string>() { "1", "2", "3", "4", "5", "7", "8" }
};
var query = data.Aggregate((pre, curr) => pre.Intersect(curr).ToList());
foreach (var item in query)
{
Console.WriteLine(item);
}
}
}
}
var result = lists.Aggregate(lists.First().AsEnumerable(), (a, l) => a.Intersect(l));
static void Main(string[] args)
{
List<List<string>> list = new List<List<string>>();
List<string> strs = new List<string>();
strs.Add("shen");
strs.Add("bao");
strs.Add("zheng");
list.Add(strs);
strs = new List<string>();
strs.Add("shen");