0

What is the use of {1} like placeholdersin the program

28th Nov 2016, 1:38 AM
Shiv Sharma
Shiv Sharma - avatar
3 Respuestas
+ 1
You use them as a way of saying where something would be in your text. for example: Console.WriteLine("Hi, my name is {0} and your name is {1}!", myName, yourName)
28th Nov 2016, 4:03 PM
Alex Bacon
Alex Bacon - avatar
0
for example: Console.WriteLine("this is your count {0}", yourVariable); the {0} is the value from your variable.
28th Nov 2016, 1:41 AM
Max_N
Max_N - avatar
0
Before I go into it, think of it as the average function. The first argument is a string which is printed. The second argument is a table (it's not a table but just say it is for a moment) filled with variables. When you're writing the first argument, you can reference a variable (via it's position in the table, starting from 0) from inside the table. You do so by typing something like {0}, {1} and so on. Here's an example. static void main { Console.WriteLine("Hey {0}. How are you, {1} ?", name, title) } Now, say that the title variable wasn't there but the {1} was. You'd get an error because it doesn't exist.
28th Nov 2016, 2:20 AM
Ben
Ben - avatar