+ 1

Why no output comes when we write ("x={0};y={1}",y,x)

30th Dec 2016, 3:33 PM
Tarun Jain
Tarun Jain - avatar
6 Antworten
+ 5
Hi, Have you assigned the value for variables x and y. We need to assign the values to declared variables. e.g. int x = 5; int y = 4; //variables has declared and values are assigned to the variables. Console.WriteLine("x={0};y={1}",y,x); //output will be x=4;y=5 I hope it's clear.
30th Dec 2016, 3:43 PM
Siddharth Warwatkar
Siddharth Warwatkar - avatar
+ 3
thanks pawan, but the x=4;y=5 is the output of the which we entered in the Console.WriteLine("x={0};y={1})",y,x);. so only one semicolon ; will be there in the output as per mention in the Console.WriteLine();
12th Jan 2017, 7:28 AM
Siddharth Warwatkar
Siddharth Warwatkar - avatar
+ 1
u forgot ; at last of the line
12th Jan 2017, 7:12 AM
pawan rastogi
pawan rastogi - avatar
+ 1
why we assign x = {0}
25th Jan 2017, 9:57 AM
Usama Nazir
Usama Nazir - avatar
+ 1
{0} is a placeholder. for example int x = 5; int y = 4; //value assigned to variables Console.WriteLine("x={0};y={1}",x,y); instead of this we can use concatenate see the below example Console.WriteLine("x="+ x + "; y="+ y); using the placeholder instead of concatenate is much simple. I hope its clear.
28th Jan 2017, 7:15 PM
Siddharth Warwatkar
Siddharth Warwatkar - avatar
0
what is the purpose of the x,y at the end of the writeline command ("x={0};y={1}",x,y); is it declaring the order of the variables to be used?
11th Feb 2017, 8:24 PM
Adam Williamson
Adam Williamson - avatar