I'm trying to sort a list alphabetically, then once the list is sorted, print the name of any element in the list which occurred more than once.
Most google searches only address comparing separate lists. I know you can compare strings, and that list elements (in this case are strings), but I'm not sure how to compare these strings since they're in the list.
using System;
using System.Collections.Generic;
namespace Challenge5alphabeticalOrderSorting
{
class MainClass
{
public static void Main(string[] args)
{
List<string> fruit = new List<string>()
{
"apple",
"mango",
"mango",
"orange",
"blueberry",
"blueberry"
};
fruit.Sort();
foreach (string f in fruit)
Console.WriteLine(f);
}
}
}