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 trial

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
231,210 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
231,210 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
231,210 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.