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

C# C# Basics (Retired) Console I/O Console I/O

I am having trouble with Challenge Task 4 of 4 Finally, read the user’s response from the console and store it back

I am having trouble with Challenge Task 4 of 4

Finally, read the user’s response from the console and store it back into the bookTitle variable.

CodeChallenge.cs
string bookTitle = "Star Wars";

System.Console.Write("Enter a book title: ");

string response;

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

By using the new function System.Console.ReadLine() discussed in the previous video lecture, you'd be able to receive user input and assign it to a variable.

string bookTitle = "Star Wars";

System.Console.Write("Enter a book title: ");

bookTitle = System.Console.ReadLine(); // read the user’s response from the console and store it back into the bookTitle variable

Like such

Ken Alger
Ken Alger
Treehouse Teacher

Dooh! William, you are too fast. :wink:

William Li
William Li
Courses Plus Student 26,868 Points

hey Ken, long time no see, how've you been doing? Wish the developers would enhance the forum by letting us see who's currently typing an response(similar to Quora), so that we don't have to double post the same answers :grinning:

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Mark;

Welcome to Treehouse!

Great job on the challenge so far. For the last task we need to set our bookTitle variable to the value that a user inputs. We can get input with System.Console.ReadLine() and assign that to our variable like so:

bookTitle = System.Console.ReadLine();

You will need the code from the previous challenges too.

Hope it helps,
Ken