C# Program to Generate Odd Numbers in Parallel using LINQ Last Updated : 21 Oct, 2021 Comments Improve Suggest changes Like Article Like Report LINQ is known as Language Integrated Query and it is introduced in .NET 3.5. It gives the ability to .NET languages to generate queries to retrieve data from the data source. It removes the mismatch between programming languages and databases and the syntax used to create a query is the same no matter which type of data source is used. In this article, we will generate odd numbers in parallel using LINQ. So, we will use ParallelQuery{TSource} to generate odd numbers in parallel. Along with it, we have to use the where and select clause to get the odd numbers Syntax: IEnumerable<int> variable = ((ParallelQuery<int>)ParallelEnumerable.Range(start, stop)).Where(x => x % 2 != 0).Select(i => i); Examples: Input: Range(start, stop)= Range(10,11) Output: 13 17 19 11 15 Input: Range(start, stop)= Range(5,8) Output: 11 5 7 9 Approach: To print odd numbers in parallel follow the following steps: Implement a parallelQuery{TSource} and mention the range(i.e., 10 to 11).Use where clause to check the modulus of y by 2 is not equal to zero.Now Select is used to check if the value of j variable is greater than or equal to the value of the variable(i.e., j).Iterate the odd numbers using foreach loop Example: C# // C# program to print odd numbers in parallel // Using LINQ using System; using System.Linq; using System.Collections.Generic; class GFG{ static void Main(string[] args) { // Implement parallel Query in the range 10 to 11 IEnumerable<int> odd = ((ParallelQuery<int>)ParallelEnumerable.Range(10, 11)) // condition to check for the odd numbers .Where(y => y % 2 != 0) // Select that odd numbers .Select(j => j); // Display the odd numbers foreach (int n in odd) { Console.WriteLine(n); } Console.ReadLine(); } } Output: 13 17 19 11 15 Comment More infoAdvertise with us Next Article C# Program to Generate Odd Numbers in Parallel using LINQ gottumukkalabobby Follow Improve Article Tags : C# CSharp LINQ CSharp-programs Similar Reads C# Program to Generate Numbers that are Multiples of 5 Using the LINQ Parallel Query LINQ is known as Language Integrated Query and it is introduced in .NET 3.5. It gives the ability to .NET languages to generate queries to retrieve data from the data source. It removes the mismatch between programming languages and databases and the syntax used to create a query is the same no matt 2 min read C# Program to Print the Numbers Greater Than 786 in an Integer Array using LINQ Language-Integrated Query (LINQ) is a uniform query syntax in C# to retrieve data from different sources. It eliminates the mismatch between programming languages and databases and also provides a single querying interface for different types of data sources. In this article, we will learn how to di 2 min read C# Program to Find the Number Occurring Odd Number of Times Write a C# program for a given array of positive integers. All numbers occur an even number of times except one number which occurs an odd number of times. Find the number in O(n) time & constant space. Examples : Input: arr = {1, 2, 3, 2, 3, 1, 3}Output : 3 Input: arr = {5, 7, 2, 7, 5, 2, 5}Out 4 min read Program to generate a random three digit even number Write a program to generate a random three-digit even number. Examples: Example 1: 482Example 2: 736 Approach: To solve the problem, follow the below idea: We can generate a random three-digit number by generating a random integer first and then modulo it by 900. Now, after modulo with 900, the rema 3 min read Counting the number of even and odd elements in a vector using a for loop? In this article, we will discuss how to find the number of even and odd elements in a vector with its working example in the R Programming Language using R for loop. Syntax:vector <- c(...) # Replace ... with the vector elementseven_count <- 0odd_count <- 0for (element in vector) { if (elem 2 min read Print all Even Numbers in a Range in JavaScript Array We have to find all even numbers within a given range. To solve this question we are given the range(start, end) in which we have to find the answer. There are several ways to print all the even numbers in a range in an array using JavaScript which are as follows: Table of Content Using for Loop in 3 min read C# | Random.Next() Method The Next() Method of System.Random class in C# is used to get a random integer number. This method can be overloaded by passing different parameters to it as follows: Next() Next(Int32) Next(Int32, Int32) Next() Method This method is used to returns a non-negative random integer. Syntax: public virt 3 min read CSES Solutions - Weird Algorithm Consider an algorithm that takes as input a positive integer N. If N is even, the algorithm divides it by two, and if N is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this, until N is one. Your task is to simulate the execution of the algorithm for a given value of 4 min read C# Program to Generate Random Even Numbers Using LINQ Parallel Query LINQ is known as Language Integrated Query and was introduced in .NET 3.5. It gives power to .NET languages to generate or create queries to retrieve data from the data source. In this article, we will generate random even numbers in parallel using LINQ. So, we will use ParallelQuery{TSource} to gen 2 min read C# Program to Find the Index of Even Numbers using LINQ Given an array, now our task is to find the index value of the even numbers present in the given array using LINQ. LINQ is known as Language Integrated Query and was introduced in .NET 3.5. It gives the power to .NET languages to generate queries to retrieve data from the data source. So to do this 2 min read Like