static method cannot implement interface method, why?

后端 未结 6 1252
刺人心
刺人心 2021-02-20 04:24
interface IXXX
{
    void Foo();
}

class XXX : IXXX
{
    public static void Foo()
    {
        Console.WriteLine(\"From XXX\");
    }
}


class Program 
{
    static          


        
6条回答
  •  野的像风
    2021-02-20 04:44

    You use interface to avoid using concrete class during instantiation. You can't access static method through instantiated class, so implementing interface methods with static methods is not allowed.

提交回复
热议问题