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

Use the System.Console.Write() method to print "Enter a book title: " to the console.

task 1 of 2

CodeChallenge.cs
print "noel" = system.Console.writeLine();

2 Answers

Balazs Peak
Balazs Peak
46,160 Points

You are trying to put a value in a variable, which doesn't exist. The WriteLine function is void, meaning that it does not have a return value.

ReadLine on the other hand, has a return value. It returns the text that the user wrote, and it returns it as a string.

The other problem is that there is no "print" type in C#. Maybe you are coming from another language, and mixing up types and commands. :)

The solution is to call the WriteLine, and pass in the text to write to the console as a parameter.

Console.WriteLine("This text will be written to the console");
Steven Parker
Steven Parker
229,744 Points

So the instructions say, "Use the System.Console.Write() method to print "Enter a book title: " to the console.".

Here's a few hints:

  • you won't use the word "print"
  • you won't need your name
  • nothing is being assigned, so you also don't need the "=" symbol
  • instead of "system.Console.writeLine()" they ask you to use "System.Console.Write()"
  • the message needs to go between the parentheses
  • the message should be "Enter a book title: "