Project each element of a sequence to an IEnumerable, and flattens the resulting sequences in CSharp
Description
The following code shows how to project each element of a sequence to an IEnumerable, and flattens the resulting sequences.
Example
//w w w . j a v a 2 s .co m
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] presidents = {"Ad", "Art", "Buch", "Bush", "Car", "land"};
IEnumerable<char> chars = presidents.SelectMany(p => p.ToArray());
foreach (char ch in chars)
Console.WriteLine(ch);
}
}
The code above generates the following result.