CSharp - Cast legacy ArrayList to ParallelQuery.


We have created a legacy collection that contains some of the codeNames' names.

We then call AsParallel, which returns an instance of ParallelQuery.

We then apply the AsOrdered operator and then so that we have something that we can use with PLINQ.

We call the Cast operator so that we transform our ParallelQuery into a ParallelQuery<string>.


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

class Program/*from w  ww  .j  a  v  a  2s  .  com*/
    static void Main(string[] args)
        ArrayList list = new ArrayList() {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"};
        IEnumerable<string> results = list
            .Where(p => p.Contains('o'))
            .Select(p => p);
        foreach (string president in results) {
            Console.WriteLine("Match: {0}", president);


Related Topic