如何去List<实体>里面实体某个属性相同的数据public class A{ public string Name { get; set; } public string Age { get; se

来源:互联网 发布:产品经理和数据分析 编辑:程序博客网 时间:2021/05/13 04:50


private class AAA { public string name { get; set; } public string arg { get; set; } }List<AAA> aaa = new List<AAA>();            AAA fff = new AAA();            fff.name = "张三";            fff.arg = "12";            aaa.Add(fff);            fff = new AAA();            fff.name = "李四";            fff.arg = "12";            aaa.Add(fff);            fff = new AAA();            fff.name = "张三";            fff.arg = "13";            aaa.Add(fff);            fff = new AAA();            fff.name = "王五";            fff.arg = "13";            aaa.Add(fff);            fff = new AAA();            fff.name = "张三";            fff.arg = "14";            aaa.Add(fff);            var ccc = aaa.Where(aa => aa.name == "张三");            Console.WriteLine(string.Join(" ", ccc.Select(aa => aa.name + " " + aa.arg).ToArray()));

0 0
原创粉丝点击