using System; using System.IO; using System.Collections; using System.Text.RegularExpressions; using System.Collections.Generic; public class WordCount { public static void Main() { Console.Write("Enter the name of the file to process: "); StreamReader input = new StreamReader(Console.ReadLine()); Dictionary count = new Dictionary(); foreach (string s in Regex.Split(input.ReadToEnd(), @"[^a-zA-Z']+")) { String s2 = s.ToLower(); if (!count.ContainsKey(s2)) count[s2] = 1; else count[s2]++; } Console.WriteLine("length = " + count.Count); foreach (string s in count.Keys) if (count[s] >= 500) Console.WriteLine(count[s] + " " + s); } }