Use LINQ to query characters in a string

image_pdfimage_print
   
 
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);
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.