+ 1

Why does c# need place holders: x=[0], y=[1] ?; how does code register these variables with placeholders?

https://code.sololearn.com/c4kl6tjzth6G/?ref=app

30th Jan 2018, 3:31 PM
JCLJM
4 Answers
+ 5
Which part of that code is troubling you mate? (Edit) Is it this one? Console.WriteLine("x = {0}; y = {1}", x, y); Well, in C# that line is much like printf in Java, C or C++, with minor difference. The first parameter defines the format "x = {0}; y = {1}" The placeholders {0} and {1} refer to the arguments passed into the second parameter, which accepts variable-length argument, accessible by index, so "x" is the first (index 0) and "y" is the second (index 1). At runtime, these placeholders will be replaced with the values of respective argument passed, hence the output "x = 10; y = 20". I hope I understood your question clearly, if not, you can post reply here : ) Hth, cmiiw
30th Jan 2018, 7:45 PM
Ipang
+ 4
Do you have a code with that syntax? link the code with your question so things can be more clear for others to see and to consider what answer is to be given : )
30th Jan 2018, 4:58 PM
Ipang
+ 2
Ok thx I get it now. You made it very clear!
30th Jan 2018, 11:51 PM
JCLJM
+ 1
its just a general question from the tutorial, i linked the syntax😅
30th Jan 2018, 7:37 PM
JCLJM