如何从Ilist中删除整个项目并使用剩余项目绑定到新Ilist [英] How to remove an entire item from Ilist and bind to new Ilist with remaining items
问题描述
嗨..
我从dll获取所需的值并绑定到Ilist并且从Ilist我需要删除特定项目,例如:
我的Ilist包含字段名称,地点,动物和东西以及许多行的值如
姓名动物物品
a aa aaa aaaa
b bb bbb bbbb
等等..
现在我想从这个Ilist和所有相应的值中移除整个Thing并绑定到新的IList并使用。
请你帮我一下这个我尝试过使用跳过linq而且一切都没有效果..请帮助
在这里你去
将您的清单设为mylist;
newList = _mylist.Remove(a = > a。 Place == aaa)。ToList();
此处符合条件的商品也将从_myList中删除。
如果您想维护原始列表并且有一个不包含某些项目的列表,那么你需要将原始列表分配给另一个变量并从那里删除项目
ie
newList = _mylist;
newList.Remove(a = > a.Place == AAA跨度>)ToList();
Hi..
I am getting a required values from dll and binding to an Ilist and from that Ilist i need a particular item to be removed like ex:
My Ilist contains fields Name,Place,Animal and Thing and many rows having the values like
Name Place Animal Thing
a aa aaa aaaa
b bb bbb bbbb
and so on..
Now i want to remove the entire Thing from this Ilist and all corresponding values and bind to new IList and use.
Please can u help me with this i have tried like using skip of linq and all but nothing has worked.. Please help
Here you go
Supose your list is mylist;
newList= _mylist.Remove(a => a.Place == "aaa").ToList();
Here the items matching the criteria will be removed from _myList also.
If you want to maintain the original list and have a list not containing some items, then you need to assign the original list to another variable and remove items from there
i.e
newList = _mylist; newList.Remove(a => a.Place == "aaa").ToList();
这篇关于如何从Ilist中删除整个项目并使用剩余项目绑定到新Ilist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!