Find numbers > 5 and < 8 in a list with a lambda expression - CSharp Custom Type

CSharp examples for Custom Type:Lambda

Description

Find numbers > 5 and < 8 in a list with a lambda expression

Demo Code



using System;//from   ww  w . ja va  2  s.c  o m
using System.Collections.Generic;
delegate void DoIt(string msg);
class Program
{
    static void Main(string[] args)
    {
        List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
        int[] numArray = numbers.ToArray();
        List<string> words = new List<string> { "one", "two", "three", "four", "five" };

        List<int> allNumbersGT5AndLT8 = numbers.FindAll(num => num > 5 && num < 8);
        foreach (int n in allNumbersGT5AndLT8)
        {
            Console.Write("\t\t {0}, ", n.ToString());
        }
    }
}

Result


Related Tutorials