Private arr2 As Array
''' <summary>
''' Gets an array containing all elements that are contained in one array but not another.
''' </summary>
''' <typeparam name="T">
''' The type of the elements in both source arrays and the array returned by the method.
''' </typeparam>
''' <param name="arr1">
''' The array in which the returned elements are present.
''' </param>
''' <param name="arr2">
''' The array in which the returned elements are not present.
''' </param>
''' <returns>
''' An array containing the elements that are present in the first array but not the second.
''' </returns>
Public Function GetUniqueElements(Of T)(ByVal arr1 As T(), ByVal arr2 As T()) As T()
Me.arr2 = arr2
Return Array.FindAll(arr1, New Predicate(Of T)(AddressOf IsObjectNotInArray(Of T)))
End Function
''' <summary>
''' Gets an array containing all elements that are contained in both of two arrays.
''' </summary>
''' <typeparam name="T">
''' The type of the elements in both source arrays and the array returned by the method.
''' </typeparam>
''' <param name="arr1">
''' The first source array.
''' </param>
''' <param name="arr2">
''' The second source array.
''' </param>
''' <returns>
''' An array containing the elements that are present in both source arrays
''' </returns>
Public Function GetCommonElements(Of T)(ByVal arr1 As T(), ByVal arr2 As T()) As T()
Me.arr2 = arr2
Return Array.FindAll(arr1, New Predicate(Of T)(AddressOf IsObjectInArray(Of T)))
End Function
Private Function IsObjectInArray(Of T)(ByVal obj As T) As Boolean
Return (Array.IndexOf(Me.arr2, obj) <> -1)
End Function
Private Function IsObjectNotInArray(Of T)(ByVal obj As T) As Boolean
Return Not Me.IsObjectInArray(obj)
End Function