How do i make these Readlines not interfere with each other
Its a menu and it has problems
26 Replies
Console.WriteLine("This is a menu test");
Console.WriteLine("there are (4) options");
Console.WriteLine("");
Console.WriteLine("Start (1) ");
Console.WriteLine("Help (2) ");
Console.WriteLine("Exit (3)");
//declaration
string choice;
do{
choice = Console.ReadLine();
if(choice == "1") {
Console.WriteLine("Yay start"); Console.WriteLine("say something"); string answer = Console.ReadLine(); Console.WriteLine(answer);
}
if(choice == "2") { Console.WriteLine("Do this"); }
if(choice == "3") { Console.WriteLine("Bye bye"); return; } else { Console.WriteLine("that was not an answer"); } }while (choice != "quit");
if(choice == "1") {
Console.WriteLine("Yay start"); Console.WriteLine("say something"); string answer = Console.ReadLine(); Console.WriteLine(answer);
}
if(choice == "2") { Console.WriteLine("Do this"); }
if(choice == "3") { Console.WriteLine("Bye bye"); return; } else { Console.WriteLine("that was not an answer"); } }while (choice != "quit");
what do you mean by interfere?
also, $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/
To post C# code type the following:
```cs
// code here
```
Get an example by typing $codegif
in chat
For longer snippets, use: https://paste.mod.gg/just do what the text says
ile show the terminal output
?
your problem isn't the readlines
your problem is the logic in your loop
wait
i got thrown off by your spacing
i mean, they're not interfering with each other because that's not a thing that can happen
i mean they are active at the same time
what does "active" mean?
i mean the else
else
{
Console.WriteLine("that was not an answer");
}
okay, so look at all your if statements
follow the logic in your code
they are all in the same lane
"lane?"
level
i think im thinking too pythonically
which is actually your problem
you have 3 independent if statements
when i give an answer to the string read it also gets picked up by the first choice variable
you are making bad assumptions
$debug and check if what you're saying is true
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Hint:
else if
i was trying to get them to think a little more methodically is a good skill to have
should do like elif or an else with a if inside
i
Try and see
Hint: hint