Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics Strings String Concatenation

Michael Robert McGowan
Michael Robert McGowan
2,075 Points

Simplified

Would it not be possible to simply add a space within the quotation marks at the end of the sentence?

4 Answers

Steven Parker
Steven Parker
216,016 Points

The tentative answer would be "yes", but it might depend on what is being done overall. Does your question pertain to something at a particular time index in the video? Please provide that time and/or a more explicit description of the situation for a more definitive answer.

UPDATE: Now that I've seen the function in question, yes, you could just add a space to every question string passed to the function. But since the "Ask" function might be used many times in the program, it makes sense to add on a space there. A more sophisticated version might even test the last character of the argument string, and add a space on only when the last character was not already a space.

Michael Robert McGowan
Michael Robert McGowan
2,075 Points

Its in ref to the first sentence that is adjusted for the users answer. A simple " " was added to the end of a sentence.

I understand explaining the concept for including that in an additional entry being included but wasnt sure if i missed why a sentence couldnt just be expanded in the case of the first example,

Its more to understand, if having spacing at the end of a question causes problems down the line id like to avoid xD

Steven Parker
Steven Parker
216,016 Points

Can you give a specific time reference in the video, and/or post the actual code line(s) involved?

Michael Robert McGowan
Michael Robert McGowan
2,075 Points

Right at the beginning of the video and around the 03:30 mark.

string entry = Ask("How many cans are you ordering?"); - This statement

Steven Parker
Steven Parker
216,016 Points

I expanded my answer above.

Michael Robert McGowan
Michael Robert McGowan
2,075 Points

Thank you, I appreciate your response, I thought it could be something like that, but thought I would ask for clarification. Thank you very much!