Count # of times each letter in alphabet appears in a word

should output the number of times each letter in the alphabet occurs in the textbox. Case sensitivity is not required

In C#, I need to write a snippet in which the user enters a word in a textbox hit OK button and the a richtextbox displays the number of times each letter in the alphabet occurs in the textbox.
So for instance, if he enters "adD" the richtextbox would show

1 A's
0 B's
0 C's
2 D's
0 E's
0 F's
....

I was thinking of putting letter that user types into an array and then the alphabet in an arraylist and iterate through that. but since i'm new to c# need some assitance.
thanks.
badtz7229Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

badtz7229Author Commented:
never mind.
alas i got it


private void button1_Click(object sender, EventArgs e)
        {
            this.richTextBox1.Clear();
            char[] arrAlphabet = { 'a', 'b', 'c', 'd','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
            foreach (char i in arrAlphabet)
            {
               
                countOccurences(i, this.textBox1.Text.ToLower());
            }

        }


        public void countOccurences(char match, String s)
        {
            int count = 0;
            char[] aString = s.ToCharArray(); 

            for (int i = 0; i < s.Length; i++) 
            {
                if (aString[i].Equals(match))   
                {
                    count++;
                }
            }

            this.richTextBox1.AppendText("\n" + count + " " + match.ToString().ToUpper() + "'s");
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.