Take and SelectMany : Take « LINQ « C# / C Sharp






Take and SelectMany

 

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);

    }
}

 








Related examples in the same category

1.Take operator outputs the first x elements, discarding the rest
2.Use Take
3.Take method
4.Partitioning Operators: uses Take to generate a sequence of the first three elements of an integer array.
5.Nested Take