+ 1

The output comes x=204.55 and y=10090 but my x is an integer?? int x = 10090; double y = 204.55; Console.WriteLine("x = {1}; y = {0}", x, y);

16th Jun 2016, 12:40 PM
Ankit
Ankit - avatar
7 Respuestas
+ 6
you just inverted them Console.WriteLine("x={0};y={1}",x,y);
16th Jun 2016, 3:15 PM
Marco Romanin
Marco Romanin - avatar
+ 5
That's because the "x={1}" doesn't use the int x, but uses the string inside the quotes. the {1} functions as a placeholder for the y variable.
16th Jun 2016, 1:26 PM
Samuel Recker
Samuel Recker - avatar
+ 3
Improper placement of Conversion Specifier. {0} Maps to First Argument & {1} to Second and So on.
16th Jun 2016, 4:14 PM
Aamir Bashir
Aamir Bashir - avatar
+ 1
This is because you have not written the bases in correct order. int x has base order 0 and double y has base order 1. Just revert them and you will get your answer.
30th Jun 2016, 8:00 PM
Rishabh Ranjan
Rishabh Ranjan - avatar
+ 1
swap the numbers 0 for x and 1 for y...
21st Aug 2016, 2:35 PM
avy7352
avy7352 - avatar
0
in Console.WriteLine("Hello {0}", yourName) why after hello "{0} " is there please explain it ??
29th Sep 2016, 4:40 AM
Arpit Farkya
Arpit Farkya - avatar
- 1
Simple words 0 comes before 1.. You made "x" = equal to 1 which made it the same as y You did the same for "y" you made it = equal to 0 which made it the same as the original number for "x"
11th Aug 2016, 7:02 AM
Red Pill
Red Pill - avatar