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#

patric Iskevi
patric Iskevi
3,663 Points

Shouldn't DistanceTo take to parameters?

Hi, Im new to programming and C#.

When Im coding along in VS I get an error message on the DistanceTo(location) It's saying that there is no argument given that corresponds to the required formal parameter 'y' of 'Point.DistanceTo(int, int)'

Cheers, Patric

1 Answer

andren
andren
28,558 Points

Your question is not tied to a video so I'm not entirely sure where in the course you are, but during this lecture a version of the DistanceTo method was added that only takes one argument. Meaning that there should be two version of DistanceTo. One which takes two arguments, and one which takes one.

If C# is complaining that you are not supplying enough arguments then that would suggest that either you have not actually added that DistanceTo method or that you are not passing a Point object (or MapLocation object) which is what that version of DistanceTo takes as an argument. Maybe you accidentally skipped that video or forgot to save the file after adding the method?

Either way if you take a look at the video and add the method shown there then that error should hopefully go away. If it doesn't then make sure that you are passing the right type of object to it.

patric Iskevi
patric Iskevi
3,663 Points

Sorry about that, and thank you for the help!