Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- partial class Program
- {
- private static readonly string[] Separators = {" ", ". ", ", ", "? ", "! ", ": ", "; "};
- private static void CountInFile(string filePath, out int linesCount, out int wordsCount, out int charsCount)
- {
- wordsCount = 0;
- charsCount = 0;
- string text = File.ReadAllText(filePath);
- linesCount = File.ReadAllLines(filePath).Length;
- string words = text.Replace(". ", " ").Replace(", ", " ").Replace("? ", " ").Replace("! ", " ").Replace(": ", " ").Replace("\r\n", " ").Replace('\n', ' ');
- while (words.Contains(" ")) { words = words.Replace(" ", " "); }
- wordsCount = words.Trim().Split(' ').Length;
- foreach (var line in File.ReadAllLines(filePath))
- charsCount += line.Length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement