[英]Are interface members abstract?
Well I know members in an interface act like they were abstract, but are they abstract actually? 我知道界面中的成员就像抽象一样,但实际上它们是抽象的吗? I mean that I do not need to use that keyword so I am not sure whether its implicit or they are not abstract technically...Hope it makes sense 我的意思是我不需要使用该关键字,所以我不确定它是隐含的还是它们在技术上不是抽象的......希望它有意义
They are not abstract - they are a contract defined by the interface. 它们不是抽象的 - 它们是由界面定义的契约。 "abstract" has a specific meaning which only applies to classes. “abstract”具有特定含义,仅适用于类。
That being said, they act very similarly to an abstract member in a class - any type implementing the interface must either implement the member or be abstract itself. 话虽这么说,它们的行为与类中的抽象成员非常相似 - 实现接口的任何类型都必须实现成员或者本身是抽象的。
They are abstract in concept, as a class that implements the interface must either implement every member or declare itself to be abstract
. 它们在概念上是抽象的,因为实现接口的类必须实现每个成员或声明自己是abstract
。
They are not abstract
in a technical sense, as only classes are abstract
. 它们在技术意义上不是abstract
,因为只有类是abstract
。
Nope. 不。 Abstract methods implicitly are virtual. 隐式的抽象方法是虚拟的。
Interface implementations do not need to be virtual. 接口实现不需要是虚拟的。 ( In fact, it is possible to explicitely implement 'conflicting' interfaces (ie interfaces declaring identical member signatures). This would not be possible with the vtable single dispatch
[1], because a single vtable slot cannot be filled twice ) ( 事实上,有可能明确地实现'冲突'接口(即声明相同成员签名的接口)。这对于vtable single dispatch
[1]是不可能的,因为单个vtable插槽不能被填充两次 )
[1] classical implementation method for virtual inheritance [1]虚拟继承的经典实现方法
They are implicitly abstract in the sense that they have no behavior defined, only the signature of the member is described. 它们是隐式抽象的,因为它们没有定义行为,只描述了成员的签名。
I don't know offhand what it looks like at the IL (and probably will never need to know, actually). 我不知道它在IL上的样子(实际上可能永远不需要知道)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.