+ 1
What is formatting and what is it used for?
K so I'm a newbie and I'm on the first lessons: https://www.sololearn.com/learn/CSharp/2584/ I don't get the displaying a formatted string thing. What is it used for? Why does it replace the {0} and {1}? Why do we write them then if they're not used? Isn't it the same to just write a value for x and y, and then print them? Please explain. Thank you in advance.
4 Réponses
+ 3
The numbers inside the {} do matter for giving the order of the sequence, {1} {0} will print the string that supposed to be formatted but in reverse as the {1} came before the {0}
+ 3
Great, thanks a lot, I got it pretty fast after reading you both and experimenting a bit!
+ 3
BTW at the time a program runs, the values that variables have is not necessarily known by the programmer which is why a programmer can't write the exact values in an output statement.