I need help with C# code. I need to list userinputs in alphabetical order.
Console.WriteLine("Give me three words");
string userInput1 = Console.ReadLine();
string userInput2 = Console.ReadLine();
string userInput3 = Console.ReadLine();
if(userInput1.CompareTo(userInput2) < 0)
this is what I have so far, but it only works for two words.
bumperino
List<string> words = new List<string>();
for (int i = 0; i < 3; i++)
words.Add(Console.ReadLine());
Console.WriteLine("---------");
foreach (var item in words.OrderBy(x => x))
Console.WriteLine(item);
Console.ReadKey();
Pay attention in class in the future, and go post in >>>/g/dpt if you need help with programming shit.
Use an a list then .sort it dumb fuck
>>56574425
Won't give answer,
Get input(s)
Store input(s)
Sort.
(or sort while you store)
Cmon mate, I don't feel like you thought about it. Just think about it and break it up.
>>56574533
Seriously ? Stop being autistic, it was assumed he could at least get the fuxking inputs
lol I am new at programming, so all this shit is new to me.
>>56574554
Was it? It seems you may be wrong.
>>56574554
Proof.
>>56574564
>>56574554
Git fuuuuuuuuuuuuuuucked
>>56574554
Still can't do it. My autism level is over 9000000
>>56574425
Put each string in an array and use the CompareTo method for each element of the array in a for loop
>>56574490
>Post solution
>No thanks
>No recognition
Here, have an even cooler looking solution that you won't understand but your professor might like.static void Main(string[] args)
{
foreach (var item in AcceptInput(3).OrderBy(x => x).ToList())
Console.WriteLine(item);
Console.ReadKey();
}
static IEnumerable<string> AcceptInput(int n)
{
for (int i = 0; i < n; i++)
yield return Console.ReadLine();
}
Not gonna give you the exact answer but think of it like this:for(x = 0; x<array.length; x++)
{
array[x].CompareTo(array[x-1])
}
>>56574765
That is, assuming you know how to use for loops. If not, I'd recommend a quick Google search.