1
I’m trying to make an algorithm that calculates the distance between two points from their coordinates (Latitude and Longitude), in my researches I ended up coming across Geocoordinate (https://docs.microsoft.com/en-us/dotnet/api/system.device.location.geocoordinate?redirectedfrom=MSDN&view=netframework-4.8). However I am not able to use the function GetDistanceTo.
Error :
"Geocordinate" does not contain a definition for "Getdistanceto" and was not can find no method of extension "Getdistanceto" that accept a first argument of the type "Geocoordinate"
Code c#:
using Nest;
using System;
namespace Gps
{
class Program
{
static void Main(string[] args)
{
double long1 = -38.527498;
double lat1 = -3.734876;
double long2 = -38.529240;
double lat2 = -3.743198;
var locA = new GeoCoordinate(lat1, long1);
var locB = new GeoCoordinate(lat2, long2);
double distance = locA.GetDistanceTo(locB);
}
}
}
I think it must be bullshit, but I’ve already spent a lot of time trying to solve this problem, I thank you in advance if someone can help me pointing out where the mistake is.



What is this
Nest? The fact that you didn’tusing System.Device.Locationmay be the reason for the error. And may be confusing with thisNest.– Maniero
@Maniero adding Nest was a recommendation from Visual Studio itself. I tried to remove it and add using System.Device.Location, as you advised, but I am unable to add a reference to System.Device.Location. Error : "Device" does not exist in the System namespace.
– Levi
I’m pretty sure I got the problem right then. Now you need to resolve the issue of adding the reference I think has already been answered in https://answall.com/q/47598/101 or https://answall.com/q/47310/101 or https://answall.com/q/40761/101 or others.
– Maniero