CSharp - AsEnumerable for PLINQ


The AsEnumerable operator converts a ParallelQuery<T> into an IEnumerable<T> and so forces sequential query execution.


public static IEnumerable<T> AsSequential<T>(
    this ParallelQuery<T> source


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

class Program/*from   w w  w.  j  av a2s .c om*/
    static void Main(string[] args)
        string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"};
        IEnumerable<string> results = codeNames
            .Where(p => p.Contains('o'))
            .Where(p => p.Contains('e'))
            .Select(p => p);
        foreach (string president in results) {
            Console.WriteLine("Match: {0}", president);