Array intersection function speed
问题 I've written a short function for array intersection and wanted to know why one function is faster than the other. 1) Dim list2() As String 'Assume it has values' Dim list2length As Integer = list2.length Function newintersect(ByRef list1() As String) As String() Dim intersection As New ArrayList If (list1.Length < list2length) Then 'use list2' For Each thing As String In list2 If (Array.IndexOf(list1, thing) <> -1) Then intersection.Add(thing) End If Next Else 'use list1' For Each thing As