Use the
Array.Sort[
^] method to sort the words, and then use a
foreach loop[
^] to print them in ascending order:
Console.WriteLine("Please enter a random word of your choice : ");
string letter1 = Console.ReadLine();
Console.WriteLine("Please enter another word of your choice : ");
string letter2 = Console.ReadLine();
string[] words = new string[] { letter1, letter2 };
Array.Sort(words);
foreach (string word in words)
{
Console.WriteLine(word);
}
Hope this helps.