+ 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);
4 Réponses
+ 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?
+ 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();
}
}
+ 7
you're very welcome brother @HEROIC 😊
+ 2
Thank you very much, Restoring faith and Don MTY your tips were very helpful :)