Tuesday, August 12, 2014

VB.NET - Find Differences Between 2 Arrays

To get an array of common items between 2 arrays, use the .Except method off of the first array.

i.e.:

Dim strDifferences As String()
Dim strUserGroups As String()
Dim strOrgGroups As String()

strDifferences= strUserGroups.Except(strOrgGroups).ToArray()

VB.NET - Find Common Items Between 2 Arrays

To get an array of common items between 2 arrays, use the .Intersect method off of the first array.

i.e.:

Dim strSimilarities As String()
Dim strUserGroups As String()
Dim strOrgGroups As String()

strSimilarities = strUserGroups.Intersect(strOrgGroups).ToArray()