Take and SelectMany : Take « LINQ « C# / CSharp Tutorial






using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
    public static void Main() {
        string[] presidents = {"Aaa", "Art", "Buch", "Bushman", "Carter", "land"};

        IEnumerable<char> chars = presidents.Take(5).SelectMany(s => s.ToArray());

        foreach (char ch in chars)
            Console.WriteLine(ch);

    }
}








22.71.Take
22.71.1.Take operator outputs the first x elements, discarding the rest
22.71.2.Use Take
22.71.3.Take method
22.71.4.Take and SelectMany
22.71.5.Partitioning Operators: uses Take to generate a sequence of the first three elements of an integer array.
22.71.6.Nested Take
22.71.7.Get the first four element in the list