C# C# Basics (Retired) Console I/O Formatting Output

kal alben-mccave
kal alben-mccave
1,195 Points

Goodnight 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") ;

CodeChallenge.cs
string firstName = Console.ReadLine() ;
Console.WriteLine(firstName) ;
Console.WriteLine("firstName" + "rocks!") ;

3 Answers

Windesson Almeida
Windesson Almeida
5,085 Points

Console.WriteLine( firstName + " rocks!") ;

Brendan Whiting
MOD
Brendan Whiting
Front End Web Development Treehouse Moderator 84,091 Points

1) 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
kal alben-mccave
1,195 Points

Thanks guys, just amazing , it worked.