+ 1
C# Code Playground freeze on loop
I'm trying to make a ascii dungeon crawler but while loop and taking input seems to freeze thinks up. Any ideas?
6 Respostas
+ 6
I'm guessing it's due to how Code Playground works. Code Playground works by preparing the code to execute along with all the inputs that will be required by the code, then the code will be executed, with each of the inputs fed to the code input mechanism as they are required, in time, so it's like a one way ticket, once the code and input is sent to SL server that's all there is to work with, in the server's point of view.
Your code does a loop, which, on each turn try to accept input (Console.ReadLine) this of course wouldn't work in Code Playground because your code asks for input repeatedly, while there was no input packed with the code, when the code was sent to the server. But of course it'll work perfectly in your IDE, because there's no such boundary (limits) in code execution.
Hth, cmiiw
+ 6
I don't think sololearn can handle, sorry just post the code here, trymaking it on a different C# IDE
+ 3
Can I see and "try my best to" see why?
+ 1
when i do exacy same on visual studio it works. was just wonder if there were limits
+ 1
i didnt save the code but this should be enough to reproduce it
while(true)
{
string input = Console.ReadLine();
switch(input) {
case "EXIT:
break;
}
}
+ 1
Thank you. I figured as much.