+ 1
Understand the {0}
static void Main(string[] args) { string yourName; Console.WriteLine("What is your name?"); yourName = Console.ReadLine(); Console.WriteLine("Hello {0}", yourName); } I was trying to understand this code but I can’t understand what the {0} mean? The rest of the code I think I understand.
1 Odpowiedź
+ 3
It substitutes a value in its place. The 0, 1 etc. inside the curly braces refer to which string should be substituted where
Here is an example:
Console.WriteLine("{0} {1} {0}", "l", "o");
This outputs "lol"