Select string length out of string array in CSharp

Description

The following code shows how to select string length out of string array.

Example


//from   www .ja  v  a 2  s.co  m

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
    public static void Main() {

        string[] names = { "A1", "B123", "C123123", "E", "W" };

        IEnumerable<string> sequence = names
         .Where(n => n.Length < 6)
         .Select(n => n);

        foreach (string name in sequence) {
            Console.WriteLine("{0}", name);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ