Finding the first word with more than 4 chars - CSharp LINQ

CSharp examples for LINQ:IEnumerable

Description

Finding the first word with more than 4 chars

Demo Code



using System;/*from  w  w w .j  a v a2  s .  co  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();
        List<string> words = new List<string> { "one", "two", "three", "four", "five" };

        string firstOverFour = words.Find(word => word.Length > 4);
        Console.WriteLine("\t{0}", firstOverFour);

    }
}

Result


Related Tutorials