Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Articulos.Cap04
- {
- public sealed class LinqExpresionLambda
- {
- public static void Main()
- {
- // 1. Fuente de datos:
- List<int> numeros = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- // Predicado:
- Func<int, bool> where = n => n < 6;
- // Selección:
- Func<int, int> select = n => n;
- // Order por:
- Func<int, string> orderby = n => n % 2 == 0 ? "even" : "odd";
- // 2. Consulta LINQ:
- var nums = numeros.Where(where).OrderBy(orderby).Select(select);
- // 3. Ejecución consulta:
- foreach (var num in nums)
- {
- Console.WriteLine (num.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement