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) Perfect var

which variable is wrong?

Hey guys I can't figure out which variable is wrong. My thoughts go to 3 possibilities:

int converted;

string downcased; ( my intuition tells me this one is very likely )

bool success;

can you help me? thanks

CodeChallenge.cs
var input = "22";

var converted = int.Parse(input);

var wheelsAreRound = true;

var downcased = "DoNuTs".ToLower();

var success = (downcased == "donuts");

var total = 0;

3 Answers

Ben Reynolds
Ben Reynolds
35,170 Points

It's the "total" variable. It needs to be a double not an int, so the value needs a decimal.

great tip Ben I made the change:

var input = "22";

var converted = int.Parse(input);

var wheelsAreRound = true;

var downcased = "DoNuTs".ToLower();

var success = (downcased == "donuts");

var total = 0.0;

but there is still something wrong

Ben Reynolds
Ben Reynolds
35,170 Points

Strange, I just tried submitting your code and it worked, does it show you an error message?

hey Ben now it worked,

I had the old code commented and for some reason that was creating an error. thanks a bunch for the help ;)