WE ARE SHARING
OUR EXPERIANCE.
BELIEVE THE POWER OF SHARE
BLOG
03 Apr
C # Linq "Intersect" Creating an Array of Common Values of Two Arrays with the Neighborhood
With C # Linq it is possible to pass common values in two different arrays to another array. In this example, a new array containing common values shared by both directories is created.
public void Linq()
{
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
var commonNumbers = numbersA.Intersect(numbersB);
Console.WriteLine("Common numbers shared by both arrays:");
foreach (var n in commonNumbers)
{
Console.WriteLine(n);
}
}
Return
Common numbers shared by both arrays:
5
8