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# Objects Inheritance Throwing Exceptions

Hailee Miu
Hailee Miu
959 Points

Overall, help with moving forward or backward.

I have made it this far but I feel like I am not grasping the concepts. For example, I know we learned about a constructor, but I couldn't tell you what it is or does. OR example, why do we have to write Map=map; Also, the challenges take me forever! and by the end it is just guess work based on previous examples.

Is it supposed to feel like this? Or should I go back and start from the beginning to get a better foundational understanding for myself? This is my first experience with coding.

4 Answers

Steven Parker
Steven Parker
229,644 Points

This is not uncommon when learning something totally new. You might enjoy this episode of The Treehouse Show where learning challenges and solutions are discussed (including some suggestions by me!).

In the meantime, maybe this will help with your specific questions:

A constructor a class method that creates a new instance (a new object) based on that class.

And you probably would not write "Map=map". I expect that "Map" is a class name and "map" is the name of a object (instance) you want to create, so you'd write:

    Map map = new Map();
Christopher Rogers
Christopher Rogers
1,250 Points

I know this is old, but I think what Hailee was referring to is the cases when you have to "initialize" a public readonly variable. I struggled with understanding this at first too.

If I understand this correctly, you're assigning "map", the parameter value passed in to the Map() method, to the readonly variable "Map".

Example:

class Map
{
    public readonly int Map;

    public Map(int map)
    {
        Map = map; //<-- this part
    }


}

After getting to this point, I agree with Hailee. it feels like a lot of steps and explanations were glossed over or skipped entirely. For example, the Constructor (in general) was mentioned for about 15 seconds, andthe 'base' constructor wasn't mentioned at all.

Hailee Miu
Hailee Miu
959 Points

Thanks!

I just now realized that there were the extra practices that pop up in my home section & a challenge that was emailed to me! Those are the types of things that will help me learn. So I am going to go back through rather than spinning my wheels with new stuff.

Steven Parker
Steven Parker
229,644 Points

A challenge was emailed to you? I haven't had that experience here myself!

Hailee Miu
Hailee Miu
959 Points

Well it wasn't like a personalized thing. It was the WooHoo you finished C# basics, make sure you keep practicing. With a link to the Practice Validation and Exceptions in C# practice workshop. I didn't know that portion of the site existed. I thought the small challenges within the course videos was it.

Steven Parker
Steven Parker
229,644 Points

There are several workshops, some reinforce the courses and some cover extra topics.