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 Encapsulation with Properties Accessor Methods

LESTER POLICARPIO
LESTER POLICARPIO
2,139 Points

private MapLocation _location;

Hi I just like to ask if in the statement

private MapLocation _location;

We are accessing the MapLocation class or this is just a name same as the MapLocation class?

1 Answer

Jon Wood
Jon Wood
9,884 Points

That statement just creates a private variable to the class called _location that has a type of MapLocation. It should later on get initialized (probably in the constructor) to a new instance of the MapLocation class. Once initialized _location will have access to the members of the MapLocation class.

This StackOverflow question may help explain it a bit better than I can. Hope it helps!