I'm working on a program where the user has to input some sort of string in, and the program will store it in a List or an Array, then count how many times the item was repeated.
The three items that are repeated the most are then displayed in descending order of number of repetitions (1st has 10 repeats, 2nd has 9, 3rd has 8)
It sounded simple. Since I have no idea how many people will input a string in, I used a list, then followed this example:
foreach (string value in list.Distinct())
{
System.Diagnostics.Debug.WriteLine("\"{0}\" occurs {1} time(s).", value, list.Count(v => v == value));
}
But for some reason, .Distinct() does not appear after my list name. Did I do something wrong? Does this have something to do with my C#, which is NOT a C# 3.0? The example never mentioned anything about adding another reference, or the like.
Is there any other way I can do this?