- 1
Someone please explain the function of each section in the code (x={0}, y={1}, x,y)
5 Réponses
+ 3
As Ihab said, "{number}" is a placeholder, that expresses where a variable will take place in a string. The code should print "x=10; y=20" to the console.
+ 2
("{number by order from 0},x ")means you want to write the value of x not x ...if x=2 then 2 is printed on screen and not x
every thing else is printed like you write it in console .writeline
if x=2 and y=4 and you want to write "x=2,y=4" then the string to put in console.writeline is ("x={0},y={1}",x,y)
note that you ahould start with 0 and increase by 1 every time you use {}
hope this helps :)
+ 1
Could you add the entire thing?
+ 1
Thank you Ken and Ihab
- 1
static void Main(string[] args)
{
int x=10;
double y=20;
Console.WriteLine("x={0}; y={1}" x,y}
}