Use LINQ to query characters in a string in CSharp

Description

The following code shows how to use LINQ to query characters in a string.

Example


   //  ww  w.java 2  s  .c  o  m
using System;
using System.Collections.Generic;
using System.Linq;

static class TestString {
    static void Main() {
        var count =
          "abc 8"
          .Where(c => !Char.IsLetter(c))
          .Count();
        Console.WriteLine(count);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ