+92 332 4229 857 99ProjectIdeas@Gmail.com

LINQ Intersect() Method (Vb.net)



The following code shows you how to extract common values from two arrays. for example arrayOne{2, 1 , 3 , 4 ,5} and secondArray{1, 3 , 5 , 7 , 8}, then after LINQ Intersect() method the output would be {1,3,5}. See the code below,






Dim numbers() As Integer = {59, 82, 70, 56, 92, 98, 85}
Dim numbers2() As Integer = {59, 12, 60, 26, 92, 100, 85}

Dim query = numbers.Intersect(numbers2)

     For Each i In query
         Console.Write(i.ToString() & " ")
     Next

Output of the program is:
59 92 85

0 comments: