How can I connect the lowest int to the correct name in my DB, Xamarin Forms
<p>I am currently working with lat, lng between different locations and gathering the distance between two different points. 
I succesfully get out the distance between different points where I currently sort them by the closest distance (in kilometer).</p>

<p>What I however am struggeling with is getting the correct name to the correct distance (that is being made out of the two different lat, lngs that is in the same row as the name).</p>

<p>So one row in the db looks like this (I have like 10 different rows with different locations with their correct latitude, longtitud):</p>

<p>Lat -----------   Lng -------  Name</p>

<p>45.032 --14.323112-----Iceland</p>

<p>I then take that Lat, Lng and with my code below I get the users current position lat, lng and i then compare the distance between the users current lat, lng position and out of it i have an int cointaining the kilometer to the closest distance.</p>

<p>How can I now connect that distance with the correct Name? </p>

<pre><code>    string thename;

    string areaLat;
    string areaLng;

    double storeLat;
    double storeLng;

    double thedistancebetweenobjects;      

    async void loadareas()
    {
        var locator = CrossGeolocator.Current;
        locator.DesiredAccuracy = 50;
        var position = await CrossGeolocator.Current.GetPositionAsync(10000); //using a plugin that gives me the users current lat, lng. 

        List &lt;int&gt; theInts = new List&lt;int&gt;();

        var getarea = await phpApi.getAreas(); //my db-callout

        foreach (var myitems in getarea["results"])
        {
            thename = myitems["Name"].ToString();

            areaLat = myitems["Lat"].ToString();
            areaLng = myitems["Lng"].ToString();
            storeLat = Double.Parse(areaLat, CultureInfo.InvariantCulture);
            storeLng = Double.Parse(areaLng, CultureInfo.InvariantCulture);

            thedistancebetweenobjects = distance(position.Latitude, position.Longitude,storeLat, storeLng, 'K'); //so the users current position lat + lng, and then the lat (storelat), and lng (storelng) i get from the db.

            int someOtherInt = Convert.ToInt32(thedistancebetweenobjects); //converting double to int

            theInts.Add(someOtherInt);
        }

        int TheSmallestInt = theInts.Min();
        System.Diagnostics.Debug.WriteLine(TheSmallestInt);
        //I succesfully get the smallest int out. But how do I connect this int with the correct name from the db?
    }
</code></pre>

<p>And this is the function that takes the two different values of lat, lng and gives me the distance result in kilometer:</p>

<pre><code>private double distance(double lat1, double lon1, double lat2, double lon2, char unit)
    {
        double theta = lon1 - lon2;
        double dist = Math.Sin(deg2rad(lat1)) * Math.Sin(deg2rad(lat2)) +
        Math.Cos(deg2rad(lat1)) * Math.Cos(deg2rad(lat2)) * Math.Cos(deg2rad(theta));
        dist = Math.Acos(dist);
        dist = rad2deg(dist);
        dist = dist * 60 * 1.1515;
        if (unit == 'K')
        {
            dist = dist * 1.609344;
        }
        else if (unit == 'N')
        {
            dist = dist * 0.8684;
        }
        return (dist);
    }

    private double deg2rad(double deg)
    {
        return (deg * Math.PI / 180.0);
    }

    private double rad2deg(double rad)
    {
        return (rad / Math.PI * 180.0);
    }
</code></pre>