How do I count the number of letters in a textbox using c#?
I specifically need the exact number of letters. example alabama has 7 letters.
after i get that number i need the number of times each letter is used. example mississippi has 1m 4 i's 4 s's and 2 p's.
thanks for interest.
How do I count the number of letters in a textbox using c#?
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: How do I count the number of letters in a textbox using c#?
Code: Select all
myTextBox.Text.Length
Then to count frequency, I think a Dictionary would be the best way. You would go through the string character by character using something like
Code: Select all
System.Collections.Generic.Dictionary myCollection = new Dictionary<char, int>();
foreach (char c in myTextBox.Text) {
if (myCollection[c] == null)
myCollection[c] = 1
else
myCollection[c]++;
}
Please edit your topic title and add [SOLVED] on the front if this does it for you.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.