If I understand your problem correctly, i.e.
- take Set A and compare it to Set B to identify the matching array elements, which in your given sets is the number 8.
- Print out the results displaying the two sets and highlight the matching array element(s) e.g. proposed output is "SetA(9 7 7 6 (8) 5 4 3)SetB"
If so, the following vb.net program code may be what you are seeking (note, it is has not been tested, but does contain the logic required and may need some tweaking)
' vb.net Code:-
' ======================
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
' Initally Create two integer arrays.
Dim setA() As Integer = {9,8,7,7,6}
Dim SetB() As Integer = {5,8,4,3}
' Find the set intersection of the two arrays.
Dim intersection As IEnumerable(Of Integer) = setA.Intersect(SetB)
'String buffer to hold intersect data
Dim Intersectoutput As New System.Text.StringBuilder
'Get setA() minus the intersect data
Dim setAless = setA.Except(intersection)
'Get setB() minus the intersect data
Dim setBless = setB.except(intersection) 'String buffer for setB() less the intersect data
'String buffers to hold sets A and B minus Intersect data
Dim setAoutput As New System.Text.StringBuilder
Dim setBoutput As New System.Text.StringBuilder
For Each id As Integer In intersection ' build text string of intersect data
Intersectoutput.Append(id)
Next
For Each id As Integer In SetAless ' build text string of SetAless less Intersect data
setAoutput.Append(id)
Next
For Each id As Integer In SetBless ' build text string of SetBless less Intersect data
setBoutput.Append(id)
Next
' Display the output in format as "SetA(9 7 7 6 (8) 5 4 3)SetB"
' complete with intersect data displayed in centre paranthesis
Console.WriteLine (setAoutput.ToString & " (" & Intersectoutput.ToString & ") " & setBless.ToString & ")SetB")
Console.ReadKey()