Question: So I'm wokring in C# programming and I am very close to getting this code to run but I can't figure out what I'm missing.

So I'm wokring in C# programming and I am very close to getting this code to run but I can't figure out what I'm missing.

Here's what I have:

#region Using directives using System; using System.Collections.Generic; using System.Text; #endregion namespace Classes { class Program { static void DoWork() { Point origin = new Point(); Point bottomRight = new Point(1366, 768); double distance = origin.distanceTo(bottomRight); Console.WriteLine($"Distance is: {distance}"); Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}"); } } class Point { private int x, y; private static int objectCount = 0; public Point() { this.x = -1; this.y = -1; objectCount++; } public Point(int x, int y) { this.x = x; this.y = y; objectCount++; } private double DistanceTo(Point other) { int xDiff = this.x - other.x; int yDiff = this.y - other.y; double distance = Math.Sqrt((xDiff * xDiff) + (yDiff * yDiff)); return distance; } public static int ObjectCount() { return objectCount; } } }

The error that pops up is this: Error CS1061: 'Point' does not contain a definition for 'distanceTo' and no extension method 'distanceTo' accepting a first argument of type 'Point' could be found (are you missing a using directive or an assembly reference?) (line 14 origin.distanceTo) What am I missing?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!