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 Methods Methods

Hello could you help me please

I don't get what he has in the paratheses in Onmap. I think the first Point is for the class and I don't know what the second point is? please help me .

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! He's writing the parameters of the function. The function is named OnMap and it takes one argument of type Point. Whatever instance of Point we send in will now be assigned to the local variable point. The first word is the type. Now, this might be a little confusing at first because you're probably used to String, int etc. But by making a class you just made your very own type! So now, we say we're going to pass in an argument of type Point and call it point. The constructor method above it takes two arguments both of type int. One will be named width and the other height.

Hope this helps! :sparkles:

patric Iskevi
patric Iskevi
3,663 Points

Hi!

So the type Point has nothing to do with the Point class we created earlier? It is just the type we have created just for this particular method?

Cheers, Patric

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi patric Iskevi! Take a look at this quote from my previous answer:

But by making a class you just made your very own type!

Let's say that we make a new variable which is going to contain a new instance of our Point class named myPoint. We then want to send that instance into a function. The function needs to be able to say what type the parameter is.

For example:

public void printPointInfo(Point point) {
  // Code to print out info about the point
}

In this simple example, we're declaring a method that prints out information about the point we're sending in. So given that we're sending in myPoint what should the type be? Int? String? Bool? No, our myPoint is of type Point.

Hope that clarifies things! :sparkles:

Aaah thanks a lot now I get it!

patric Iskevi
patric Iskevi
3,663 Points

Great Jennifer, thanks for taking the time to clarify it to me!