简体   繁体   English

接口成员是抽象的吗?

[英]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.

相关问题 语义驱动接口中的允许抽象成员与抽象类 - Semantics driving the allowed abstract members in an interface vs an abstract class 使用抽象接口成员的具体实现实现接口 - Implement interface using concrete implementations of abstract interface members 我试图在一个类中实现抽象类和接口,只有接口成员被调用,而抽象方法没有? - I tried to implement abstract class and interface in a class and only interface members got called and abstract method didnt? 对于MVP设计中的View界面,IView成员应该有多抽象? - For the View interface in MVP design, how abstract should the IView members be? 为什么使用override关键字实现抽象类的抽象方法,而不实现接口成员? - Why override keyword is used to implement abstract method of an abstract class but not to implement interface members? 覆盖抽象类的抽象成员 - Overriding abstract members of abstract classes 为什么C#抽象类继承具有实现至少一个接口名称所需的名称签名的接口成员? - why are C# abstract classes that inherit interface members with the name signature required to implement at least one of them? C#8中Interface成员的默认实现是否与克服抽象类的多重继承问题有关? - Does default implementation of Interface members in C# 8 relates to overcome multiple inheritance problem of abstract class? 如何通过只有一个类型而不使用反射来访问一个类型实现的 static 抽象接口成员? - How to access a type's implemented static abstract interface members by having only a type without using reflection? 使用接口成员实现接口 - Implementing an interface with interface members
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM