Hi guys. I was talking about using the 'Intersect' method, but as I mentioned, it is essentially designed for comparing 2 arrays / lists, instead of 3 or more. However, these can be 'stacked' to add more arrays / lists into the comparison, but only if you have access to all of them directly, and not just iterating through them one by one. This method creates a new IEnumerable(Of ) type object each time it is called, but the result of one can be compared to the next, if that type of comparison procedure will work OK here. Below is an example of what I am talking about. However the problem with this example is that we are not really utilizing the List(Of List(Of )) object here in the end. We are accessing the individual List objects by their individual variables. Also, keep in mind that a List object is vb.net based, so its entries are zero based index (first item / element is at index of zero, not one).
This code outputs the correct two values to the iLogic Log window, but the end process needs to be able to work with the List of Lists somehow, which is awkward, since normal iterations only work on one instance at a time, not two at a time, and collections can have uneven numbers of entries, so some testing must be included to make sure the next element is actually there before comparison can be done.
Dim oListOfLists As New List(Of List(Of String))
Dim oList1 As New List(Of String)
oList1.Add("Param1")
oList1.Add("Param2")
oList1.Add("Param3")
oListOfLists.Add(oList1)
Dim oList2 As New List(Of String)
oList2.Add("Param1")
oList2.Add("Param3")
oList2.Add("Param4")
oListOfLists.Add(oList2)
Dim oList3 As New List(Of String)
oList3.Add("Param1")
oList3.Add("Param3")
oList3.Add("Param4")
oList3.Add("Param5")
oListOfLists.Add(oList3)
Dim oNewCommonList As List(Of String) = oList1.Intersect(oList2).Intersect(oList3).ToList
If oNewCommonList.Count > 0 Then
For Each sEntry In oNewCommonList
Logger.Info(sEntry)
Next sEntry
End If
Wesley Crihfield

(Not an Autodesk Employee)