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

ali raafat
ali raafat
444 Points

can anyone help me

i am stuck at this part

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

1 Answer

andren
andren
28,558 Points

You have the assignment backwards, in programming you need to have the variable you are assigning a value to on the left side of the equal sign, and the value you want to assign on the right side. Like this:

height = 10 + height;

It's also worth noting that when you want to set something equal to itself plus something else there is a shortcut in the form of the += operator, using that you can shorten the code to this:

height += 10;

Either way will work for this task but it's worth keeping that shortcut in mind since it is shorter and more convenient, and you will see it quite often in other developer's code.