Overload Method Static + Dynamic Failure

I have come across this several times over the past week, and am curious to know the reason - I had Google, but I could not find anything directly relevant.

I have a class with a dynamic method, and I can add a static method with the same interface:

public class MyClass
{
    public int MyMethod()
    {
        //do something #1;
    }

    public static int MyMethod()
    {
        //do something
    }
}

This is normal, but if I try to call a static method from a dynamic method, replacing # 1 with return MyClass.MyMethod(), I get the error message "The call is ambiguous between the following methods or properties: MyClass.MyMethod () and MyClass.MyMethod ().
If the static method is deleted, the error changes to "An object reference is required ..", which makes sense.

, ? , , .
?

EDIT: , , VS, .
, " , , "

+5
2

, SO, , .

public class MyClass
{
    public int MyMethod()
    {
        return 0;
    }

    public static int MyMethod() //Here compiler says, that you've already got method MyMethod with same parameter list
    {
        return 0;
    }
}

,

this

:

(, ) , . , params, .

-:

, , , , .

: , , , , . , , , , , .

+1

, ? , . ?

, MyClass MyClass. , . , .

0

All Articles