moni moni

moni moni

  • NA
  • 2
  • 361

confusion about code

Apr 7 2019 12:20 PM
Hi
I am new to C#, I just finished watching a part of a tutorial. I am confused about a line of code, which I did not understand. here is the code,
  1. int userValue = 2;  
  2. string message = (userValue == 1) ? "boat" : "car";  
  3. Console.WriteLine("{1} - {0}", userValue, message);  
  4. Console.ReadLine();  
output: car - 2
 
my question is for line 3. why its print "car" first? shouldn't it be "2" first?
because it says here
 
Console.WriteLine("{1} - {0}", userValue, message);  
 
doesn't it mean {1} assign to 'userValue' & {0} assign to 'message'? 
I am really confused here. 
I am sorry if I post this question in wrong section.
 
thanks
Shumon

Answers (1)