[英]How to remove stuff from a list in C#?
I have a list of structs: 我有一个结构列表:
list<structure>;
But I want to remove the specific stuff by ID. 但我想通过ID删除特定的东西。
Example: item with ID 55. 示例:ID为55的项目。
So how I can reomve a stuff from list? 那我怎么能从列表中重新提出一些东西呢?
I have an ID in the struct as public string stuffID;
我在结构中有一个ID作为
public string stuffID;
How can I do this? 我怎样才能做到这一点?
To remove everything with an ID of 55: 要删除ID为55的所有内容:
List<Structure> list;
list.RemoveAll(structure => structure.ID == 55);
list = list.Where(item => item.id != 55).ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.