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 Inheritance in Code

Ilya Sikharulidze
PLUS
Ilya Sikharulidze
Courses Plus Student 1,073 Points

"new" keyword

Can someone please explain to me, why are we writing : map.OnMap( new MapLocation(0,0)); Thanks!

2 Answers

Steven Parker
Steven Parker
231,269 Points

The "new" keyword creates an object, so this one creates a new "MapLocation". But the "OnMap" method is defined as taking a Pont object as an argument. So passing it the newly-created MapLocation option was done to demonstrate that a MapLocation is also a Point.

This line and several others shown in the video were for demonstration only and will not be part of the final program.

It creates an object.