0% found this document useful (0 votes)
149 views1 page

C# Program To Generate Odd Numbers

This C# program uses LINQ and parallel processing to generate odd numbers between 20 and 2000. It uses ParallelEnumerable.Range to create a parallel query of numbers in that range, filters them with a Where clause to select only the odd numbers, and then outputs the results. The program compiles and runs successfully, displaying all odd numbers from 20 to 2000 in no particular order due to the parallel processing.

Uploaded by

Rajthilak24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views1 page

C# Program To Generate Odd Numbers

This C# program uses LINQ and parallel processing to generate odd numbers between 20 and 2000. It uses ParallelEnumerable.Range to create a parallel query of numbers in that range, filters them with a Where clause to select only the odd numbers, and then outputs the results. The program compiles and runs successfully, displaying all odd numbers from 20 to 2000 in no particular order due to the parallel processing.

Uploaded by

Rajthilak24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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 [Link];
6 using [Link];
7
8 class Program
9 {
10

static void Main(string[] args)

11

{
IEnumerable<int> oddNums =

12

((ParallelQuery<int>)[Link](20, 2000))
13

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

14

.Select(i => i);

15

foreach (int n in oddNums) { [Link](n); }

16

[Link]();

17
18 }

You might also like