SelectMany Prototype: with ? operator : SelectMany « 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 = {"A", "Art", "Buch", "Bush", "Carter", "land"};

        IEnumerable<char> chars = presidents
         .SelectMany((p, i) => i < 5 ? p.ToArray() : new char[] { });

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








22.64.SelectMany
22.64.1.A More Complex Example of the First SelectMany
22.64.2.SelectMany Prototype
22.64.3.SelectMany Prototype: with ? operator