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 trialkal alben-mccave
9,556 PointsGoodnight Can you help me with this string concatenation. C# basics
Goodnight I am suppose to concatenate the word rocks to firstName as part of my coding challenge after the lesson, just cant seem to get it right. the 3rd line of code is where im getting the problem.
string firstName = Console.ReadLine() ; Console.WriteLine(firstName) ; Console.WriteLine("firstName " + " rocks") ;
string firstName = Console.ReadLine() ;
Console.WriteLine(firstName) ;
Console.WriteLine("firstName" + "rocks!") ;
3 Answers
Windesson Almeida
Full Stack JavaScript Techdegree Graduate 19,903 PointsConsole.WriteLine( firstName + " rocks!") ;
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points1) They want the variable firstName
again, not the string literal "firstName".
2) You need to add a space in " rocks" otherwise it will be smushed together when you concatenate. (This seems to be the case in the first version of the code in your question but not the 2nd, not sure why).
kal alben-mccave
9,556 PointsThanks guys, just amazing , it worked.