prints the unique elements of two integer arrays : Union « LINQ « C# / C Sharp






prints the unique elements of two integer arrays

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

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

        var uniqueNumbers = numbersA.Union(numbersB);

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

 








Related examples in the same category

1.Use Linq to union two arrays
2.prints unique letters from Product and Customer names
3.Union Operator
4.Union does appends one sequence to another with duplicates removed: