SelectMany

Input: IEnumerable<TSource>
Lambda expression: TSource => IEnumerable<TResult> or (TSource,int) => IEnumerable<TResult>

SelectMany concatenates subsequences into a single flat output sequence.

 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] fullNames = { "A B", "C D E", "F G" };

        IEnumerable<string> query = fullNames.SelectMany(name => name.Split());

        foreach(String s in query){
           Console.WriteLine(s);
        }
    }
}

The output:


A
B
C
D
E
F
G
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.