I haven't touched C#.NET in a while so I'm getting quite rusty at this. I have a question that hopefully someone can answer here.
I have a program that accepts string inputs. My goal is to make it so every XX seconds it runs a private function that will take the inputs and sort them into whichever strings have been used the most, returning the most common word, then erase the inputs to be ready for the next batch.
For example, if the program asks for a favorite color and 10 users type in stuff like "RED" "BLUE" "RED" "ORANGE" "PINK" "ORANGE" "RED" "BLUE" "GREEN" "BLACK" I want the function to first look through and figure out that RED was said 3 times (and thus should return RED).
But for the life of me my brain is failing me. I'm pretty sure I need an array of somekind but I can't remember how to go about sorting it based on the occurrences of a string within that array.
Psuedo code wise, I think I would need something like
Array [word, counter]
If (word already exists) counter++ else (add word, set counter to 1)
Then just sort by the counters.
However, how to actually implement that into C#... welp...
I know this is kind of a stupid question but Google is returning a bunch of overly complicated or totally unrelated things. So thanks for any help with this!