This Function show you how to use Intersect to create one sequence that contains the common values shared by both arrays.
public void InterSectExample()
{
int[] A = { 1,2,3,4,2,1,3,5,4,6,4,2,1,9 };
int[] B = { 1, 3, 5, 7, 8,4,10,11 };
var commonNumbers =A.Intersect(B);
Console.WriteLine("Common numbers shared by both arrays:");
foreach (var n in commonNumbers)
{
Console.WriteLine(n);
}
}
LINQ-Intersect to create one sequence that contains the common values shared by both arrays.
This Blog show you how to use Intersect to create one sequence that contains the common values shared by both arrays.


Join the conversation! Your thoughts help the community grow.