linq Union

linq Union

public static void Union()
        {
            int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
            int[] numbersB = { 1, 3, 5, 7, 8 };

            var uniqueNumbers = (numbersA.Union(numbersB)).OrderBy(p => p);

            Console.WriteLine("Unique numbers from both arrays:");
            foreach (var n in uniqueNumbers)
            {
                Console.WriteLine("{0}", n);
            }
        }
The returned the unique elements from the two array.
Output

Linq Set Operators

linq Union linq Union Reviewed by Bhaumik Patel on 7:03 PM Rating: 5