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

Jeremy Hansen
Jeremy Hansen
282 Points

What am I doing wrong?

Having issues with the console.readline concept. What am I doing wrong here

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

System.Console.ReadLine();
string bookTitle = " My Favorite Book";

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Jeremy,

You have all the correct elements there, just not quite being used the right way.

First, the challenge did not ask for a "Hard-Coded" string being assigned to the variable bookTitle. This is supposed to hold what the user enters into the ReadLine() method. So, you need to be assigning this to the variable instead of a hard-coded value. Basically, you just need to (more or less) combine those two lines of code like so:

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

string bookTitle = System.Console.ReadLine();

Keep Coding! :dizzy:

Steven Parker
Steven Parker
231,269 Points

You need to store the response from calling ReadLine.

Calling the function doesn't do anything unless you save the return value somewhere. I see you created the variable on the next line but you stored a literal string in it.

So you just need to eliminate that string and re-arrange the other stuff so that you create the variable and store the result of calling the function into it.