How to put values into a C# function and get a result?
<p>I'm sure this will be very easily answered and can be attributed to me being more than a little 'wet behind the ears' with C# but I'm having an issue calling and putting values into a function before then writing the response on screen.</p>

<p>The function and call works perfectly in PHP (where I have a bit more experience) so I think the issue lies more with using the correct syntax in C# than anything else. Maybe I'm still trying to write it with my PHP hat on?</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace postcode
{
  public partial class postcode_finder : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
        //Example lat/long values entered below

        Response.Write(distance(32.9697, -96.80322, 29.46786, -98.53506, "M"));
    }

    public 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;

    }

    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    //::  This function converts decimal degrees to radians             :::
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

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

    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    //::  This function converts radians to decimal degrees             :::
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    public double rad2deg(double rad)
    {
        return (rad / Math.PI * 180.0);
    }

  }
}
</code></pre>

<p>The error I get says that 'the best overloaded method match for 'postcode.postcode_finder.distance(double, double, double, double, char)' has some invalid arguments'.</p>

<p>Where am I going wrong? Here's hoping someone with a little more know-how can give me a nudge in the right direction.</p>

<p>Thanks</p>
