using System.Text.RegularExpressions;
public static void Main()
Console.Write("Enter any message:");
string t1 = Console.ReadLine();
Console.WriteLine("there are {0} words, ", CountWords(t1));
static int CountWords (string s)
return Regex.Matches(s, @"[A-Za-z0-9']+").Count;