linq Intersect

linq Intersect

public static void Intersect()
        {
            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("{0}", n);
            }
        }
The returned the common elements from the two array.
linq Intersect

Output
linq Intersect

Linq Set Operators
linq Intersect linq Intersect Reviewed by Bhaumik Patel on 6:59 PM Rating: 5