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

Did you declare the `height` variable as an int?

not sure what is wrong here

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

Nevermind i have solved it.

string heightInput = "168";

int height = int.Parse(heightInput);

Just needed to put the variable name instead

Daniel Bell
Daniel Bell
17,178 Points

You have declared 'height' variable as a string. int.Parse() is a function that accepts a string as an argument and returns an integer.

I recommend reviewing the previous few videos again.

1 Answer

Steven Parker
Steven Parker
231,248 Points

The variable is being declared as the wrong type:

string height = int.Parse 168;
//^^^^
//should be "int" instead