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!
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
Mohamed M.KamelCourses Plus Student 752 Points
how to initialize a string in c#?
i want an answer
string bookTitle; bookTitle = "name";
Jennifer NordellTreehouse Teacher
Hi there! There's not really anything wrong with your code other than a misinterpretation of what they mean. They want you to declare the variable and initialize it. This means that the declaration and the initial value should happen on the same line.
So, if I alter your code just a bit, it passes:
string bookTitle = "name";
This declares a string named
bookTitle and initializes it by giving it a beginning value.
Hope this helps!