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 trialPatrick Cooks
187 PointsUse Console.WriteLine to print the contents of the firstName variable to the screen. need help with this question
Use Console.WriteLine to print the contents of the firstName variable to the screen.
string firstName = Console.ReadLine();
string firstName = Console.WriteLine;
2 Answers
ALFRED MOHENU
1,499 PointsWhen you run your program, Console.ReadLine() allows the user to enter some information which is then stored in the string variable, firstName. You can display the contents of the variable to the console by inserting the variable into Console.WriteLine() like this ---> Console.WriteLine(firstName); Re-watch the video if you don't really understand the topic.
Roman Fincher
18,267 PointsLet's see if this helps...
In the first line, we use the equals sign because we are assigning an input from the console to an object. For WriteLine(), we aren't setting anything equal to something else, just writing the value of a string to standard output (the console).
Instead of assigning something with an "=", we need to tell WriteLine() what we want it to display.
See the WriteLine() msdn and try to figure out how you're misusing it. Also, look at the compiler errors in "preview"... they would have started pointing you in this direction.