+ 1

I want to be asked what's my name, then i will type it, and another text will appear which will be hello (my name). help pls ?!

that's my code what's wrong with it ?! string yourName; Console.WriteLine("what is your name?"); yourName = Console.ReadLine(); Console.WriteLine("hello {0}" ,yourName);

23rd Apr 2017, 3:39 PM
HEROIC
HEROIC - avatar
4 Antworten
+ 10
It works for me on code playground. You could also write the last line like: Console.WriteLine("hello "+yourName); Maybe you forgot a semi-colon or caps in your actual code?
23rd Apr 2017, 3:51 PM
Rrestoring faith
Rrestoring faith - avatar
+ 8
your way is working good.. but you might wanna try this way also :- using System ; public class ExampleClass { public static void Main() { Console.WriteLine ( "Greetings! What is your name?" ); Console.Write( "My name is: " ); string name = Console.ReadLine(); Console.WriteLine ( "Nice to meet you, " + name); Console.ReadKey(); } }
23rd Apr 2017, 4:07 PM
Don MTY
Don MTY - avatar
+ 7
you're very welcome brother @HEROIC 😊
23rd Apr 2017, 5:04 PM
Don MTY
Don MTY - avatar
+ 2
Thank you very much, Restoring faith and Don MTY your tips were very helpful :)
23rd Apr 2017, 5:03 PM
HEROIC
HEROIC - avatar