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!

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# Objects Object-Oriented Programming Fields

Ruslan T
Ruslan T
1,706 Points

tower, map is assigned but it's value is never used

Game.cs(7,17): warning CS0219: The variable `tower' is assigned but its value is never used

Game.cs(13,15): warning CS0219: The variable `area' is assigned but its value is never used

I get this error when I try to compile the program, can anyone help?

namespace TreehouseDefence


class Game

    public static void Main()


      Tower tower = new Tower();

      Map map = new Map();

      map.width = 8;

      map.height = 5;

      int area = map.width * map.height;




2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! To be clear, you are not getting errors, you are are getting warnings. There's a difference here. And the warning is saying exactly what it means. You've declared a variable named tower but haven't used it. If you take a look at 3:29 of the video linked to this challenge, you'll see that the line with tower is not present. Now, this might happen in a later video, but as of right now, it is not used.

Again, this is just a warning. It's just letting you know that you've declared a variable you haven't actually used. But that doesn't mean you won't use it later :smiley:

Hope this helps! :sparkles:

Ahmed M
Ahmed M
4,008 Points

that is not a error you just didn't use the value