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
16,920 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
186,321 Points

The variable is being declared as the wrong type:

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