Concatenation without Using the Concat Operator
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program/*from w ww. ja v a2 s . co m*/ { static void Main(string[] args) { string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"}; IEnumerable<string> items = new[] { codeNames.Take(5), codeNames.Skip(5) } .SelectMany(s => s); foreach (string item in items) Console.WriteLine(item); } }
In the following example we created an array consisting of two sequences:
Then we are calling the SelectMany operator on the array of sequences.
Concat operator allows only two sequences to be concatenated together, this technique allows an array of sequences.