Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Pierce Mulligan
1,106 PointsQuick multiple choice question, looking for explanation.
Which line of code will allow you to retrieve an entry from a user into a variable called: userValue ? A.
Console.ReadLine(userValue); B.
string userValue = Console.ReadLine(); C.
string userValue = Console.ReadLine; D.
string userValue = Console.WriteLine("Please enter a value:");
I selected D. which was incorrect. What is the correct answer, and why?
What will be written to the command window?
int userValue = 2; string message = (userValue == 1) ? "boat" : "car"; Console.WriteLine("{1} - {0}", userValue, message);
A.
2 - car B.
1 - boat C.
2 - boat D.
car - 2
Here I selected D. and it was the correct answer, but it was a bit of an educated guess on my behalf, and I would like someone to explain the logic to me.
Thanks!
P.S The language is C#