I want to compare two string arrays. I don\'t know how to implement this in vb.net.
Let\'s say I have two arrays
Dim A() As String = {\"Hello\", \"H
With Linq use Except() to find the differences between the two arrays and Intersect() to find which elements are in both arrays.
Imports System.Linq
Module Module1
Sub Main()
Dim A() As String = {"Hello", "How", "Are", "You?"}
Dim B() As String = {"You", "How", "Something Else", "You"}
Console.WriteLine("A elements not in B: " + String.Join(", ", A.Except(B)))
Console.WriteLine("B elements not in A: " + String.Join(", ", B.Except(A)))
Console.WriteLine("Elements in both A & B: " + String.Join(", ", A.Intersect(B)))
Console.ReadLine()
End Sub
End Module
Results:
A elements not in B: Hello, Are, You?
B elements not in A: You, Something Else
Elements in both A & B: How