View Single Post
Old 12-28-2006, 04:20 AM   #14 (permalink)
Sep102
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

Quote:
Originally Posted by BeneathTheStars View Post
Got it to do as i want.. thanks very much mordero, Sep102, Jeff, and Nochte!

Here it is:
Code:
private void CountTypes()
        {
            Dictionary<string, int> types = new Dictionary<string, int>();
            foreach (string s in m_types)
            {
                if (!types.ContainsKey(s))
                    types.Add(s, 1);

                else
                    types[s] += 1;
            }
            foreach (string filetype in types.Keys)
            {
                if (types[filetype] == 1)
                    continue;
                
                SetText4(filetype + " " + types[filetype] + "\r\n");
            }
        }

Once i get the whole thing done, i will post it!
So, from what I understand from this method, you want to go through all of the types, find each unique type and count how many times it appeared in the original array, then call SetText4 for any type that appeared more than once in the original array (at least, that's what the if(types[filetype] == 1) check will do, make it skip any types that appeared only once). You would need to get rid of that if you wanted to do what the original code was supposed to have been doing, calling SetText4 for every type.

Last edited by Sep102; 12-28-2006 at 04:24 AM.
Sep102 is offline   Reply With Quote