日期:2014-05-20 浏览次数:20831 次
var empList = new Dictionary<int,List<Employee>>();
Random r = new Random();
int length = 10000;
Console.WriteLine(string.Format("开始装载数据({0})...", length));
List<Employee> _List = new List<Employee>();
for (int i = 0; i < length; i++)
{
var e =new Employee()
{
ID = i,
FName = "A" + i,
Age = r.Next(0, 100),
Sex = r.Next(0, 2) == 1 ? 'F' : 'M'
};
if (empList.TryGetValue(e.Age, out _List))
_List.Add(e);
else
empList[e.Age] = new List<Employee>() { e };
}
IEnumerable<Employee> list = new List<Employee>();
List<Employee> list1 = new List<Employee>();
foreach (var item in empList)
{
IEnumerable<Employee> ie = item.Value.Where(p => p.Sex == 'F');
list1.AddRange(ie);
list.Concat(ie);
}
Console.WriteLine(list.ToList().Count);
Console.WriteLine(list1.Count);