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

391 Points

Why am I getting error

Why is my code generating an error?

Error message is: "Bummer! Did you set 'bookTitle' using the equals sign and a string value?"

string bookTitle;
bookTitle = "Dune";

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Your code would work... outside the challenge. However, for some odd reason even they don't explicitly say it... they clearly want the declaration and the initialization on the same line. Don't ask me why. When I couldn't find anything wrong with your code I tried it all on one line... and what do you know? It worked!

string bookTitle = "Dune";

I'm almost of the opinion that this should be reported to Treehouse for problems with clarity. Because nowhere in the challenge instructions does it say that you must do the assignment and the initialization on the same line.

391 Points

Thank you Jennifer, got it to work. Wow, that was really bugging me because I had tested my code in the Workspace and it worked fine there. And I tried initialization in a single line, but I still had the original declaration in the line above (from the previous task), so that was giving me an error too.

Thanks for the clarification.