且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

静态方法无法实现接口方法,为什么呢?

更新时间:2022-04-10 04:59:13

请参阅此线程从 JoelOnSoftware 描述这背后的原因。

See this thread from JoelOnSoftware describing the reasons behind this.

基本上接口是消费者与供应商之间的合同,以及一个静态方法属于类,而不是类作为这样的每个实例

Basically the interface is the contract between the consumer and the provider, and a static method belongs to the class, and not each instance of the class as such.

上也是如此处理完全一样的问题,前面一个问题:
为什么不C#允许静态方法来实现接口?

An earlier question on SO also deal with the exact same question: Why Doesn't C# Allow Static Methods to Implement an Interface?