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 matter which type of data source is used. In this article, we are going to generate the numbers from the given range which are multiples of 5 parallelly. So to do our task we are using the inbuilt ParallelQuery class to generate numbers in parallel.
Where start is the starting number and stop is the ending number.
Input : Range(3, 20) Output : 10 15 20 5 Input : Range(1,10) Output : 5 10
In the below example, first, we will create a number collection of IEnumerable types range from 3 to 20 then generate numbers that are multiples of 5 present in between the given range using Where(n => n% 5 == 0) function. After generating numbers that are multiples of 5 we will display these numbers on the output screen.
Numbers are: 10 15 20 5