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.

Jakob Kristiansen
3,057 Pointsobj is Point?
I am wondering how the parameter obj of type System.Object knows that it is a Point object (or any other type). Essentially, how is this evaluated
if (!(obj is point)) { return false; }
obj does not know about other attributes of the point class e.g. X and Y so it is not entirely clear to me how the above comparison works.
1 Answer

evanpavan
5,025 PointsJakob, it is actually really simple. The key thing here is that it's doing this check:
if (!(obj is Point)) { return false; }
I bolded Point because in your code Point was lower case referring to the object. In Jason's code Point is uppercase referring to the Point class. The Point class is a 'type'. This 'is' operator is a method that checks to see what class the object passed in belongs to.
So the check that Jason was doing in the lesson was, "Is the object 'obj' of type 'Point' ". This check doesn't need to know if the object has an X or Y value or what those values are. All it needs to know is if the object in question that was passed in is of the Point class.
Simon Coates
28,693 PointsSimon Coates
28,693 Pointscan't tell you. However, values inherit from object and object has a GetType method that returns Type objects. Uncertain if this is how the 'is' keyword operates or whether 'is' is just something built in that you need to accept.