public static class ExtensionMethods { public static string[] Wrap(this string text, int max) { var charCount = 0; var lines = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return lines.GroupBy(w => (charCount += (((charCount % max) + w.Length + 1 >= max) ? max - (charCount % max) : 0) + w.Length + 1) / max) .Select(g => string.Join(" ", g.ToArray())) .ToArray(); } }
var WordCount = Regex.Matches(text, @"\b[A-Za-z0-9]+\b").Count;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)