0

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??

5th Apr 2018, 7:52 PM
Alexander Rapino
Alexander Rapino - avatar
1 Answer
0
{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
5th Apr 2018, 8:16 PM
sneeze
sneeze - avatar