How to count word occurrences in an array of strings using c#?
<p>I'm new to programming, and I am trying to write a program that take in an array of strings (each index of the array being a word) and then count the occurrences of each word in the string. This is what I have so far:</p>

<pre><code>        string[] words = 
        {
            "which", 
            "wristwatches", 
            "are", 
            "swiss", 
            "wristwatches"
        };

        Array.Sort (words);
        for (int i = 0; i &lt; words.Length; i++) 
        {
            int count = 1;
            for(int j = 1; j &lt; words.Length; j++)
            {
                if (words [i] == words [j])
                {
                    count++;
                }
            }
            Console.WriteLine ("{0}   {1}", words[i], count);
        } 
</code></pre>

<p>Ideally, I would like the output to be something like:</p>

<p>are   1</p>

<p>swiss   1</p>

<p>which   1</p>

<p>wristwatches   2</p>
