Having an ambiguity issue in C#
<p>I have the follow program:</p>

<pre><code>    static void Main(string[] args)
    {
        CaptureFunction(MyFunction); // This line gets an error: "The call is ambiguous between the following methods or properties: CaptureFunction(System.Func&lt;object,object&gt;) and CaptureFunction(System.Func&lt;int,int&gt;)"
        CaptureFunction(MyFunction2);
    }

    static void CaptureFunction(Func&lt;object,object&gt; myFunction)
    {
        myFunction.DynamicInvoke(3);
    }

    static void CaptureFunction(Func&lt;int, int&gt; myFunction)
    {
        myFunction.DynamicInvoke(3);
    }

    static object MyFunction(object a)
    {
        if (a is int)
            return ((int) a)*3;
        return 0;
    }

    static int MyFunction2(int a)
    {
        return a * 3;
    }
</code></pre>

<p>I am trying to figure out why I am getting an ambiguity error at that line. They clearly have two different parameter signatures. I understand that an <code>int</code> can also be boxed into an <code>object</code>, however, I would except C# to call the <code>CaptureFunction(Func&lt;int, int&gt;)</code> method if I pass actual <code>int</code> values, otherwise it should call the other <code>CaptureFunction()</code> method. Can someone please explain this and please offer a possible work around?</p>
