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 trialwael dibs
827 PointsHow to solve the problem of the concatenation code in the exam
i wrote the code in the right format but i dont know why the compiler makes error
using System;
string firstName;
firstName = Console.ReadLine();
//firstName = firstName + " rocks !"
System.Console.WriteLine(firstName + " rocks !");
//Console.WriteLine( " rocks !" );
3 Answers
Sebastian Wilson
15,710 PointsThe answer below works
There is no space between rocks and the ! but there is a space before hand. So it's " rocks!" Not "rocks !"
var firstName = Console.ReadLine();
Console.WriteLine(firstName + " rocks!");
Kjetil Lorentzen
13,360 PointsThe code challenges are extremely sensitive when entering the text they ask for. In your case you should enter " rocks!" Instead of " rocks !".
Also, for the code challenge the using System directive is not necessary.
string firstName = Console.ReadLine();
Console.WriteLine(firstName + " rocks!");
Jennifer Nordell
Treehouse TeacherHi! I got your request to answer, but see that two others have done a great job already. To reiterate what they've said, challenges are very strict and when they ask for you to do something your output (generally speaking) must be exactly as they want it to the letter. This includes capitalization, punctuation, spelling, and even spacing.
Kjetil Lorentzen is correct. There is no need for the using directive. This is what is causing your compiler error.
Tip Going forward into the challenges it's important to try not to do anything the challenge doesn't explicitly ask for. Even if functional outside the challenge, it can cause the challenge to fail.
Happy coding!
wael dibs
827 Pointswael dibs
827 Pointsthank you Sebastian it works