Here's an example of how to calculate the distance between two points on Earth using the Haversine formula in C#:
main.cs515 chars15 lines
This method takes in four parameters, which are the latitude and longitude of the two points, and an optional radius of the Earth (default value is 6,371 km). It returns the distance between the two points in the specified unit (km in this example).
To use this method, you can simply call it with the latitude and longitude of the two points:
main.cs75 chars2 lines
This will calculate the distance between Tel Aviv, Israel and San Francisco, USA.
gistlibby LogSnag