I’m scrubbing 5 files for a specific value. I dont anticipate any different values, BUT since this is for my own educational purposes, I would like the application to count, compare and print the most popular value.
for example:
ArrayList arrName = new ArrayList();
arrName.Add("BOB")
arrName.Add("JOHN")
arrName.Add("TOM")
arrName.Add("TOM")
arrName.Add("TOM")
The result I would like is going to be TOM but being a novice, I really dont know how to move forward.
Any thoughts, suggestions or examples are greatly appreciated.
Thank you.
You can use a Dictionary (.NET 2.0+) to hold the repeated count of each value:
If you’re using C# 3.0 (.NET 3.5 +) then use: