C# Program to Find Greatest Numbers in an Array using WHERE Clause LINQ
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 learn how to find the greatest numbers in an array using WHERE Clause LINQ. Here, we will get the numbers that are greater than a particular number in the given array.
Input: Array of Integers: 100,200,300,450,324,56,77,890 Value: 500 Output: Numbers greater than 500 are: 890 Input: Array of Integers: 34,56,78,100,200,300,450,324,56,77,890 Value: 100 Output: Numbers greater than 100 are: 200,300,450,324,890
To display the greatest numbers in an array using WHERE Clause LINQ follow the following approach:
- Store integer(input) in an array.
- The sum of the elements is calculated using the for loop.
- The numbers which are greater than particular value is checked using where function.
- By using the LINQ query we will store the numbers in an iterator.
- Now the iterator is iterated and the integers are printed.
Numbers that are greater than 100 are : 200 300 450 324 890