Question: having a problem. Efficiency. I know very little about efficiency in coding, but I'm learning. Searching through these arraylists of strings for item1 and when found adding item2 to a new arrayList. The logic is great. Works fine. But takes about 30-40 seconds as there are 700 elements in arrLoList \* 10 000 elements in arrCoList. 

Now contains drops out as soon as it finds the item1, so I can't really improve on that. Would it help at all to cut some characters off the end of the arrCoList's strings?

How else could I improve this? I think changing from arrayLists?

```
For Each item1 In arrLoList             
        For Each item2 In arrCoList

            If arrCoList.contains(item1) Then

                arrNewList.Add(item2)

            Else
                intCouldntfind += 1     'not finding 7 million 

            End If

```

Answer: 
First, i would not use an old `ArrayList` which always requires to box/unbox the objects to their actual type(`string` here). Instead i would use a strongly typed `List(Of String)`.

Second, you can use [`Enumerable.Except`](http://msdn.microsoft.com/en-us/library/bb300779.aspx) to get the set difference which is quite efficient since it uses a `HashSet` internally.

```
Dim sw = New System.Diagnostics.Stopwatch ' measure time 
Dim rnd As New Random ' create random strings
Dim loList = New List(Of String)(700)
Dim coList = New List(Of String)(10000)

' initialize with sample data
For i = 1 To 700
    loList.Add(String.Format("Item: {0} Random-Value: {1}", i, rnd.Next(1, 1000)))
Next
For i = 1 To 10000
    coList.Add(String.Format("Item: {0} Random-Value: {1}", i, rnd.Next(1, 1000)))
Next

sw.Start()

' *** Here is all you need: '
Dim newList = loList.Except(coList).ToList()

sw.Stop()

```

Result: **3 milliseconds** at a max
You are doing an innecesary nesting:

This should be quite a bit faster:

```
For Each item1 In arrLoList   
    If arrCoList.contains(item1) Then          
        For Each item2 In arrCoList               
            arrNewList.Add(item2)
        Next  
     End If
Next

```