+ 2

Why can't sololearn code play ground accept user input in c#

I tried writing a code that accepts the user's name and print out a message to him/her but when I run it,it comes blank... No errors too.can someone explain to me why.

5th Oct 2017, 9:16 PM
Ben Acq
Ben Acq - avatar
9 Respuestas
+ 5
1) Console.WriteLine("Please enter your name"); 2) Console.ReadLine(); 3) name=Console.ReadLine(); You do that in line 3. Please remove line 2, it takes your input and does not do anything with it.
5th Oct 2017, 9:56 PM
sneeze
sneeze - avatar
+ 3
every readline needs to be separated by a return the first readline is not assign to a variable
5th Oct 2017, 9:48 PM
sneeze
sneeze - avatar
+ 3
Thank you very much @sneeze and Jamie
5th Oct 2017, 10:03 PM
Ben Acq
Ben Acq - avatar
+ 3
@sneeze I tried your method,and it worked.👍
5th Oct 2017, 10:09 PM
Ben Acq
Ben Acq - avatar
+ 2
@Sneez yeah I get the window this is the code: Class{ main{ string name; Console.WriteLine("Please enter your name"); Console.ReadLine(); name=Console.ReadLine(); Console.WriteLine("Hello "+ name); } } pls is something wrong with the code? I get the window for the input but when I type in the name and run it prints only the " Hello".
5th Oct 2017, 9:42 PM
Ben Acq
Ben Acq - avatar
+ 1
@Jamie I tried assigning the user input to the string "name" so that whatever he/she types will be assigned to that string. or that's not how it works?
5th Oct 2017, 9:54 PM
Ben Acq
Ben Acq - avatar
+ 1
@sneez Ok thanks I will try it out and see what happens
5th Oct 2017, 9:55 PM
Ben Acq
Ben Acq - avatar
0
Can you show use the code ? Do you get the user input window ?
5th Oct 2017, 9:31 PM
sneeze
sneeze - avatar