- 1

Someone please explain the function of each section in the code (x={0}, y={1}, x,y)

5th Jan 2017, 4:41 AM
Steve Muthiga
Steve Muthiga - avatar
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.
5th Jan 2017, 6:19 AM
Dao
Dao - avatar
+ 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 :)
5th Jan 2017, 5:34 AM
Ihab Taleb
Ihab Taleb - avatar
+ 1
Could you add the entire thing?
5th Jan 2017, 4:45 AM
Dao
Dao - avatar
+ 1
Thank you Ken and Ihab
7th Jan 2017, 9:20 AM
Steve Muthiga
Steve Muthiga - avatar
- 1
static void Main(string[] args) { int x=10; double y=20; Console.WriteLine("x={0}; y={1}" x,y} }
5th Jan 2017, 4:50 AM
Steve Muthiga
Steve Muthiga - avatar