Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Getting a number of integers which are more than some value using Aggregate

I have a task to find a number of integers which are more than some specified value using Aggregate. For example, there is a list of integers

List<int> list = new List<int>() { 100, 200, 300, 400, 500 }; 

On this list I need to find the number of elements of this list which are more than 250. There should be 3 of them, but I need to use Aggregate there somehow to find this number.

Can anybody help please?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use Count, which is designed for counting:

 using System.Linq;

 ...

 List<int> list = new List<int>() { 100, 200, 300, 400, 500 };

 ...

 int result = list.Count(item => item > 250);

If you insist on Aggregate:

 int result = list.Aggregate(0, (s, a) => a > 250 ? s + 1 : s); 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!