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

Rahul Gupta
Rahul Gupta
667 Points

Whats wrong with this code ? CodeChallenge.cs

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

CodeChallenge.cs
System.Console.Write ("Enter a book title:");
Daniel Tkach
Daniel Tkach
7,608 Points

The only strange thing I see is the space after Write, but that shouldn't give you a compilation error. What's the error you get? And what's the complete code and challenge about?

8 Answers

Daniel Tkach
Daniel Tkach
7,608 Points

What about the semicolon at the end? Is there a way you can attach a snapshot? Or tell me what exactly is your code, if it's that, then the semicolon is missing.

Rahul Gupta
Rahul Gupta
667 Points

The challenge is :

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

I have tried removing the space as well and the error is : Bummer! Make sure to use the exact message from the instructions. Note the trailing space. Copy/paste if you like!

Daniel Tkach
Daniel Tkach
7,608 Points

Oh I see. Well in a string, whatever is within the quotes " ", a space does matter. See if there's a space after the colon. "Enter a book title: " instead of "Enter a book title:"

It will even look better with a space otherwise when you use this in real life a person will start typing after the colon, and this looks bad: Enter a book title:The Best Story compare with: Enter a book title: The Best Story which looks clearer.

Rahul Gupta
Rahul Gupta
667 Points

This is really strange because i am making sure that is no extra spaces , i have even tried to copy paste . When i do the same code in Visual Studio it works just fine but here it does not

Daniel Tkach
Daniel Tkach
7,608 Points

The thing is, the space must be there, it is in the example, so you have to include it in your answer too :)

The question says "Enter a book title: " and you are entering it without the space "Enter a book title:", that's why you are not getting the pass.

Rahul Gupta
Rahul Gupta
667 Points

Thanks a lot for being patient with this . Trust me i have a space after the colon :

System.Console.Write("Enter a book title: ") even this does not work .

Rahul Gupta
Rahul Gupta
667 Points

It worked ..... Ahh thank you so much for the help . I think it was the space somewhere . I refreshed the page and wrote the code again - System.Console.Write("Enter a book title: ") and it worked ... yay . Thanks a lot

Daniel Tkach
Daniel Tkach
7,608 Points

You are welcome Rahul. Let's help each other learn this stuff which is no simple thing. See you around!

Rahul Gupta
Rahul Gupta
667 Points

Thank you again . Looking forward to that :)

Pierre Gadea
Pierre Gadea
4,542 Points

Try the Preview tab. You might see a message there? Where are you typing the code? You may need to have it inside a method. If all else fails, try logging out and logging back in to retry on a fresh page.

Rahul Gupta
Rahul Gupta
667 Points

I got this one fixed . Thank you for taking the time to help :)