Concat by not using the Concat Operator in CSharp

Description

The following code shows how to concat by not using the Concat Operator.

Example


  // w ww.j  a  v a  2 s. c om

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
    public static void Main() {
        string[] presidents = {"ant", "arding", "rison", "eyes", "over", "ackson"};
        IEnumerable<string> items = new[] {
                                   presidents.Take(5),
                                   presidents.Skip(5)
                                  }.SelectMany(s => s);
        foreach (string item in items)
            Console.WriteLine(item);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ