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) 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 ;)