C# Code Playground freeze on loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

5th Oct 2017, 11:33 PM
Pieter Schutte
Pieter Schutte - avatar
6 Answers
+ 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
6th Oct 2017, 1:21 AM
Ipang
+ 6
I don't think sololearn can handle, sorry just post the code here, trymaking it on a different C# IDE
5th Oct 2017, 11:38 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Can I see and "try my best to" see why?
5th Oct 2017, 11:40 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
when i do exacy same on visual studio it works. was just wonder if there were limits
5th Oct 2017, 11:40 PM
Pieter Schutte
Pieter Schutte - avatar
+ 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; } }
5th Oct 2017, 11:45 PM
Pieter Schutte
Pieter Schutte - avatar
+ 1
Thank you. I figured as much.
6th Oct 2017, 8:09 AM
Pieter Schutte
Pieter Schutte - avatar