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

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
210,475 Points

The variable is being declared as the wrong type:

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