The source code to check all items of a float array is greater than 5.0 using Linq, is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
//C# program to check all items of a float array
//is greater than 5.0 using Linq.
using System;
using System.Linq;
class LinqDemo
{
static void Main(string[] args)
{
float[] numbers = { 8.2F, 11.2F, 7.6F, 8.3F, 5.5F,6.4F };
bool isgreater = false;
isgreater = numbers.All(x => x > 5.0F);
Console.WriteLine("All floating pointer is greater the 5.0? --> " + isgreater);
}
}
Output:
All floating pointer is greater the 5.0? --> True
Press any key to continue . . .
Explanation:
In the above program, we created a LinqDemo that contains the Main() method. In the Main() method we created an array of float numbers.
isgreater = numbers.All(x => x > 5.0F);
The above code will return a boolean value, where we check all elements of the array are greater than 5.0 if any one of them is less than 5.0 then All() method will return false otherwise it will return true.
Program:
The source code to check all items of a float array is greater than 5.0 using Linq, is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a LinqDemo that contains the Main() method. In the Main() method we created an array of float numbers.
The above code will return a boolean value, where we check all elements of the array are greater than 5.0 if any one of them is less than 5.0 then All() method will return false otherwise it will return true.