5

Okay why in the world is Console.Readline() in C# such a bitch? So I was working on this small simple chat application using C# and I had a super-freaked-out-ugly-code-vending team mate who volunteered to build the server side code. After trudging through his elaborate and highly complicated plan of working for the server, I decided to make the client accordingly and for close to an hour I had no clue why the program was sending an empty password field. A few debug messages later I realised that a line of code was getting skipped. The compiler was happily ignoring the Console.ReadLine that asked for the password from the user. I swear I felt like one of those parents in the shopping mall with their really disobedient kids.
Btw, I still haven't figured out how to fix the bloody thing.

PS: First rant post woohooo!

Comments
  • 2
    1. welcome to devrant
    2. this is unlikely, are you saying you can hit a breakpoint before Console.ReadLine, step through the code, and it would just jump past that statement?
  • 2
    How is that even possible O.o
  • 0
    @xalez Okay I didn't mean that the compiler actually jumps over it. It does get executed but the ReadLine() does not actually wait for an entry. Instead it (probably) just takes something (I'm assuming something to do with the previous carriage return) from the buffer. This is in fact a common issue.
  • 0
    Just to clarify, it doesn't actually skip the line of code. That would indeed be weird. It was skipping asking for password because the ReadLine function just takes something (I think) from the buffer instead.
Add Comment