我试图在对象列表中查找原始类型的代码,并将结果获取到新列表中。从列表中获取结果<T> C#
我一直在寻找像谷歌这样的东西,但每个人都谈论列表之间的交集,我想要这样的东西。
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);
你已经拥有了(where),只需用'=='而不是'=' – Sayse