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 trialTravis Russom
Courses Plus Student 286 PointsChallenge Task 3 of 3
I thought I was doing what the video showed me, but I've went back and watched it over more than I care to recollect. I'm on the last task of the challenge involving the concatenation process. Here is what I have, what am I missing? These videos are not all that explanatory on a few things, or it could be I'm just not getting it at all. Thanks
string firstName; System.Console.ReadLine(); System.Console.WriteLine("You've entered (firstName)" + " rocks!"); This is what I'm getting from the video and what it's asking you to do in the question. This is frustrating me.
2 Answers
Dane Parchment
Treehouse Moderator 11,077 PointsWell let's start by looking at your problem, basically, you are trying to manipulate an empty variable. The instructions for step 1 state to create a string called firstName and set it equal to a console.read method return value. However, you create and do not initialize the variable firstName, and then simply call the readLine method without making it the value of the variable here let me show you:
This is what you did
string firstName;
Console.ReadLine();
This is what you were supposed to do:
string firstName = Console.ReadLine();
For the second task you were supposed to display the contents of firstName this can be done like so:
string firstName = Console.ReadLine();
Console.WriteLine(firstName);
Finally you need to concatenate the string "rocks" at the end of the firstName variable value let's do that now:
string firstName = Console.ReadLine();
Console.WriteLine(firstName + " rocks!");
I think you should rewatch the video on variables so that you can properly learn or remember how to set them up and intialize them.
Alan Mattanó
Courses Plus Student 12,188 PointsYou can make a concatenation in this way:
"You've entered " + "Travis"
and will print an output: "You've entered Travis"
You can put Travis into a string name: firstName , that contains "Travis"
"You've entered " + firstName
and will print an output: "You've entered Travis"
or in this way:
firstName + " rocks!"
and will print an output: "Travis rocks!"
Adam Mazurick
Courses Plus Student 7,653 PointsAdam Mazurick
Courses Plus Student 7,653 Points@mod FYI you're missing a semicolon after rocks and it won't compile.
Dane Parchment
Treehouse Moderator 11,077 PointsDane Parchment
Treehouse Moderator 11,077 PointsAdam Mazurick Fixed it, thanks for pointing that out.