+ 1
Why no output comes when we write ("x={0};y={1}",y,x)
6 odpowiedzi
+ 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.
+ 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();
+ 1
u forgot ; at last of the line
+ 1
why we assign x = {0}
+ 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.
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?