Why we add zero on console.write("hello{0}") | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we add zero on console.write("hello{0}")

18th Dec 2017, 2:07 PM
aysar
1 Answer
0
You need the braces and the number, when you have an optional argument to substitute this {0} with an Integer, character, Double, etc. Else it is not required. The number indicates the argument to substitute into, and the numbering starts from 0. Eg : Integer age = 17; String name = "Guy1"; Console.Write("{0} is {1} years old.", name, age);
18th Dec 2017, 2:15 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar