C# ReadLine and WriteLine | SoloLearn: Learn to code for FREE!


C# ReadLine and WriteLine

{ string yourName; Console.WriteLine("What is your name?"); yourName = Console.ReadLine(); Console.WriteLine("Hello {0}", yourName); } why is there a {0} after "Hello" in line 6??

4/5/2018 7:52:16 PM

Alexander Rapino

1 Answer

New Answer


{0} is a placeholder for the variable. In this case it is is the variable yourName Console.WriteLine("Hello {0}", yourName); This wil print "Hello Alexander" Console.WriteLine("{0} Hello", yourName); This wil print "Alexander Hello" https://code.sololearn.com/c9Sy3XspIEZB/#cs