[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I need help with C# code. I need to list userinputs in alphabetical

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 16
Thread images: 1

File: Keyboard.jpg (8KB, 307x164px) Image search: [Google]
Keyboard.jpg
8KB, 307x164px
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.
Thread posts: 16
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.