SelectMany Prototype: with ? operator

image_pdfimage_print

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 chars = presidents
.SelectMany((p, i) => i < 5 ? p.ToArray() : new char[] { }); foreach (char ch in chars) Console.WriteLine(ch); } } [/csharp]

This entry was posted in LINQ. Bookmark the permalink.