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 (Retired) Perform Converting Strings to Integers

how to Add 10 to height and store result back into height?

a bit confused

CodeChallenge.cs
string heightInput = "168";
int height = int.Parse(heightInput);

I also do not understand this code challenge. Please help.

1 Answer

Steven Parker
Steven Parker
210,476 Points

You could explicitly assign "height" to itself plus the value, or just use the "addition assignment" operator instead:

height += 10;

I don't understand what it wants us to do? int height = heightInput + 10;

Steven Parker
Steven Parker
210,476 Points

You're done with "heightInput" now that you passed the previous task. Now you only need to increase the converted value by 10.

Try one of the suggestions I made above.

I used your example, height += 10; and it gives me a try again answer. I typed it the way you put it.

Steven Parker
Steven Parker
210,476 Points

If I paste that line directly into the challenge after yours, it passes task 2. Note that if you put it in before the task 1 validation, it produces the wrong value for that step and would indeed result in a "try again".

You are right. Thank you so much for your help and patients.