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# 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!