Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda