CSharp - Parallel LINQ Introduction

Introduction

Parallel LINQ, known as PLINQ, processes the objects in the source enumeration concurrently.

Demo

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

class Program/*from  w  w w.j a v  a 2 s  .com*/
{
    static void Main(string[] args)
    {
        string[] codeNames = {
              "Python", "Java", "Javascript", "Bash", "C++", "Oracle"};

        string president = codeNames.AsParallel()
            .Where(p => p.StartsWith("J")).First();
            
        Console.WriteLine(president);
    }
}

Result

Related Topics