A C# program that analyzes character frequency in text files and displays them in descending order of occurrence.
This script reads a text file (in this case, harry-potter.txt) and counts the occurrences of each character, then outputs the results sorted by frequency from most to least common.
- .NET SDK (10.0 or later recommended)
- A text file named
harry-potter.txtin the same directory as the script
Run the script using the dotnet script runner:
dotnet LetterFrequencyTest.csOr make it executable:
chmod +x LetterFrequencyTest.cs
./LetterFrequencyTest.csThe script outputs each character with its rank and occurrence count:
# 1 - char: [space] - occurrences: 150000
# 2 - char: e - occurrences: 95000
# 3 - char: t - occurrences: 70000
...