Use LINQ to query characters in a string
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); } }