// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Linq; using System.Text.RegularExpressions; namespace E { public class Program { public static void Main(string[] args) { string s = "Hello World ::1234321:: Good bye"; Console.WriteLine(Regex.Replace(s, "\\D", "").Length); Console.WriteLine(s.ToCharArray().Where(char.IsDigit).Count()); Console.WriteLine((from c in s.ToCharArray() where char.IsDigit(c) select c).Count()); Console.WriteLine(s.ToCharArray().Count(char.IsDigit)); } } }