The current code is compiling O.K at the moment and if a duplicate is found it is automatically removed. is there anyway the user can chose if they would like to keep the duplicate before removing. Or is there another method i can look at that would be suitable.
static void Main(string[] args)
{
List<string> dictionaryList = new List<string>();
string input;
Console.Write("Please enter a string or END to finish: ");
input = Console.ReadLine();
while (input.ToUpper() != "END")
{
if (!dictionaryList.Contains(input)) // This is where i am looking of a user response of y/n too add duplicate string
dictionaryList.Add(input);
Console.Write("Please enter a string or END to finish: ");
input = Console.ReadLine();
}
dictionaryList.Sort();
Console.WriteLine("Dictionary Contents:");
foreach (string wordList in dictionaryList)
Console.WriteLine("\t" + wordList);
}
}
}
Try with following code: