A predicate lambda expression with an array's Find() method: - CSharp Custom Type

CSharp examples for Custom Type:Lambda

Description

A predicate lambda expression with an array's Find() method:

Demo Code



using System;/*  w  ww  . j a  v  a 2s. c  o m*/
using System.Collections.Generic;

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();

        Console.WriteLine("\n1. Finding the first number greater than 4: ");
        int firstGreaterThanFor = Array.Find(numArray, n => n > 4);
        Console.WriteLine("\t{0}", firstGreaterThanFor.ToString());
    }
}

Result


Related Tutorials