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 Variables

ultan gannon
ultan gannon
5,876 Points

I don't know what I'm doing wrong! I think I'm declaring the string right but it says I'm wrong

I'm writing

string bookTitle = HHGTTG;

put it says it is wrong.

I've checked the MicroSoft webpage and they say that is how it should look. I've tried putting "HHGTTG" in quotation marks but it doesn't work either.

CodeChallenge.cs
string bookTitle;
string bookTitle = HHGTTG;
Patrick Masters
Patrick Masters
15,776 Points

Hey Ultan!

So in this example you're actually declaring your variable twice by having "string" at the beginning. Also - you're not assigning a string, to the string.

So you have 2 options:

string bookTitle;
bookTitle = "HHGTTG"; //quotes make it a string

or, if you want to do all in one line:

string bookTitle = "HHGTTG";

Make sure you mark the answer as compete if this helped :)

1 Answer