LINQ-Union to create one sequence that contains the unique values from both arrays.

This Function show you how to use Union to create one sequence that contains the unique values from both arrays.

            public void UnionExample()
        {

            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 uniqueNumbers = A.Union(B);

            Console.WriteLine("Unique numbers from both arrays:");
            foreach (var n in uniqueNumbers)
            {
                Console.WriteLine(n);
            }

        }

Ebook Download
View all
Learn
View all