Use Concat to merge two integer arrays into a single sequence : Concat « LINQ « C# / C Sharp






Use Concat to merge two integer arrays into a single sequence

 
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 allNumbers = numbersA.Concat(numbersB);

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

 








Related examples in the same category

1.use Concat with array elements
2.Uses Concat to merge the names of all customers and products
3.Concat Prototype
4.Concatention by Using the Concat Operator
5.Concat appends one sequence to another