You are on page 1of 1

1 C# Program to Generate Odd Numbers in Parallel using

LINQ
This C# Program Generates Odd Numbers in Parallel using LINQ. Here it Provides a set of
methods for querying objects that implement ParallelQuery{TSource} to generate odd numbers
inparallel.
Here is source code of the C# Program to Generate Odd Numbers in Parallel using
LINQ. The C# program is successfully compiled and executed with Microsoft Visual
Studio. The program output is also shown below.
1 /*
2

* C# Program to Generate Odd Numbers in Parallel using LINQ

*/

4 using System;
5 using System.Linq;
6 using System.Collections.Generic;
7
8 class Program
9 {
10

static void Main(string[] args)

11

{
IEnumerable<int> oddNums =

12

((ParallelQuery<int>)ParallelEnumerable.Range(20, 2000))
13

.Where(x => x % 2 != 0)

14

.Select(i => i);

15

foreach (int n in oddNums) { Console.WriteLine(n); }

16

Console.ReadLine();

17
18 }

You might also like