+ 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.
9 odpowiedzi
+ 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.
+ 3
every readline needs to be separated by a return
the first readline is not assign to a variable
+ 3
Thank you very much @sneeze and Jamie
+ 3
@sneeze I tried your method,and it worked.👍
+ 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".
+ 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?
+ 1
@sneez Ok thanks I will try it out and see what happens
0
Can you show use the code ?
Do you get the user input window ?