C
C#11mo ago
HD-Fr0sT

How do i make these Readlines not interfere with each other

Its a menu and it has problems
No description
26 Replies
HD-Fr0sT
HD-Fr0sTOP11mo ago
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");
Jimmacle
Jimmacle11mo ago
what do you mean by interfere? also, $code
MODiX
MODiX11mo ago
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/
HD-Fr0sT
HD-Fr0sTOP11mo ago
$code
MODiX
MODiX11mo ago
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/
Jimmacle
Jimmacle11mo ago
just do what the text says
HD-Fr0sT
HD-Fr0sTOP11mo ago
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");
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");
ile show the terminal output
Angius
Angius11mo ago
?
HD-Fr0sT
HD-Fr0sTOP11mo ago
No description
Jimmacle
Jimmacle11mo ago
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
HD-Fr0sT
HD-Fr0sTOP11mo ago
i mean they are active at the same time
Jimmacle
Jimmacle11mo ago
what does "active" mean?
HD-Fr0sT
HD-Fr0sTOP11mo ago
i mean the else else { Console.WriteLine("that was not an answer"); }
Jimmacle
Jimmacle11mo ago
okay, so look at all your if statements follow the logic in your code
HD-Fr0sT
HD-Fr0sTOP11mo ago
they are all in the same lane
Jimmacle
Jimmacle11mo ago
"lane?"
HD-Fr0sT
HD-Fr0sTOP11mo ago
level i think im thinking too pythonically
Jimmacle
Jimmacle11mo ago
which is actually your problem you have 3 independent if statements
HD-Fr0sT
HD-Fr0sTOP11mo ago
when i give an answer to the string read it also gets picked up by the first choice variable
Jimmacle
Jimmacle11mo ago
you are making bad assumptions $debug and check if what you're saying is true
MODiX
MODiX11mo ago
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.
Angius
Angius11mo ago
Hint: else if
Jimmacle
Jimmacle11mo ago
i was trying to get them to think a little more methodically when is a good skill to have
HD-Fr0sT
HD-Fr0sTOP11mo ago
should do like elif or an else with a if inside i
Angius
Angius11mo ago
Try and see Hint: hint
Jimmacle
Jimmacle11mo ago
when
Want results from more Discord servers?
Add your server