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
186,662 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
186,662 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
186,662 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.