Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

How do you put a question with multiple outcomes on a program in C#?

SofieMLPA
SofieMLPA

How do you put a question with multiple outcomes on a program in C#?

3 years ago

Voters

Comments

TopNew
2
DynamicSquid
DynamicSquid

display the question
display user input
if user input is something
then do something

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid

Can you explain in detail. I'm new and I have no idea what half of what you said means. Srry....

3 years ago
2
DynamicSquid
DynamicSquid

@SofieMLPA
so you're trying to ask the user a question, and do something according to different responses?

3 years ago
2
DynamicSquid
DynamicSquid

@SofieMLPA
do you know how to get the user's input?

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid

isn't it Console.ReadLine? and an int or string?

3 years ago
2
DynamicSquid
DynamicSquid

@SofieMLPA
yes, what about if statements?

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid

I'm literally watching a tutorial about that right now. I think i have it down, but i'm about to test the code.

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid
Yeah, the tutorial was not helpful. Any advice?

3 years ago
2
DynamicSquid
DynamicSquid

@SofieMLPA
what are you learning from?

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid

youtube.....I'm broke...

3 years ago
2
DynamicSquid
DynamicSquid

@SofieMLPA
try to find a tutorial on a website

3 years ago
1
SofieMLPA
SofieMLPA

@DynamicSquid

Any specific websites you would recommend?

3 years ago
1
DynamicSquid
DynamicSquid

@SofieMLPA
try to find one yourself, one that suits your learning style

3 years ago
2
SofieMLPA
SofieMLPA

@DynamicSquid

Ok! Thanks for the advice!

3 years ago
1
SofieMLPA
SofieMLPA

@iterate

wow! Thanks so much for the advice. I'll check it out.

3 years ago
2
BlueComet
BlueComet

@SofieMLPA
if this helped can you mark it as the answer

3 years ago
1
CodeLongAndPros
CodeLongAndPros

multiple outcomes on a program

string input = Console.ReadLine(); if (input == "hello") { foo(); } else if (input == "spam") { Console.WriteLine("I don\'t like spam!"); } else { bar(); }
3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
That is the code snippet to get input from the user and do stuff based on the input. Swap hello and spam for whatever input you want and foo(); and Console.WriteLine(...); for whatever code you want.

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Wait, Imput as in like, what the answers are or the question I want to ask?

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA

Happy to help

Please mark this as the answer if it aided you.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
input is what the user said. If you asked the user for their name, input would have their name.

3 years ago
Load more