+ 1
Why does c# need place holders: x=[0], y=[1] ?; how does code register these variables with placeholders?
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
+ 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 : )
+ 2
Ok thx I get it now. You made it very clear!
+ 1
its just a general question from the tutorial, i linked the syntaxđ