Lambda语句中创建自定义类型时,也可指定某种特定类型,方法是在new与{}之间写上类型名称

如:

var fc =...
ChildFath = fc.Select(c => new Child_Father { child = c.child, father = c.father }).Distinct().Where(c => c.father != c.child).ToList();

也可不事先定义类型

var aa=fc.Select(c => new  {  c.child,  c.father }).Distinct().Where(c=>c.child==aa").ToList();

posted on 2017-09-28 12:18  mol1995  阅读(157)  评论(0编辑  收藏  举报

导航