我试图在对象列表中找到原始类型的代码并将结果放入一个新列表中。
我一直在谷歌中寻找类似的东西,但每个人都在谈论列表之间的交集,我想要这样的东西。
int AssocCode = 2;
//Entity.ID
//Entity.Name
//Entity.AssociationCode
List<Entity> list = new List<Entity>();
list.Add(new Entity(1, "A", 1));
list.Add(new Entity(2, "B", 2));
list.Add(new Entity(3, "C", 3));
list.Add(new Entity(4, "D", 2));
list.Add(new Entity(5, "E", 2));
/*I want the results for finding that code inside the collection**/
List<Entity> newList = list .... find/intersect/select/remove/whatever (x => x.AssociationCode = AssocCode);