比较2个列表对象 [英] Comparing 2 list objects
本文介绍了比较2个列表对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有两个要比较的列表对象.我认为最好的方法是使用Linq.好的,我的2个列表是List(Of PermissionObj),所以基本上我试图返回两个列表都不通用的项目的列表.
Hey guys I have two list objects that I am trying to compare. I think the best way to do is use Linq. Ok my 2 lists are List(Of PermissionObj) so basicaly I am trying to return a list of the items that are not common to both lists.
Dim _listOfAllPermissionGroups As List(Of PermissionGroupObj)
Dim _listOfUnSelectedGroups As List(Of PermissionGroupObj)
For Each objMember As PermissionGroupObj In _listOfAllPermissionGroups
For Each objUserPermissions As PermissionGroupObj In _listOfUserPermissionGroups
If objMember.PermissionGroupId = objUserPermissions.PermissionGroupId Then
_listOfUnSelectedGroups.Remove(objMember)
Exit For
End If
Next
Next
我使用了Foreach循环,但是由于任何原因,匹配的对象都不会被移除.
谢谢大家.
I have used a Foreach loop but for whatever reason the matched object doesn''t get removed.
Thanks guys.
推荐答案
关注:
http://msdn.microsoft.com/en-us/library/bb300779 [ ^ ]
Follow :
http://msdn.microsoft.com/en-us/library/bb300779[^]
这篇关于比较2个列表对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文