Difference
Compare interfaces to abstract classes: An abstract class can have implementations or abstract members without implementation. However, an interface can never have any implementation; it is purely abstract. Because the members of an interface are always abstract, the abstract keyword is not needed with interfaces.
Similarly
Similarly to abstract classes, you can never instantiate an interface.
Interface之简介
(1)An interface has neither constructors (how can you construct something that you can’t instantiate?)
(2)nor fields (because that would imply some internal implementation).
(3) An interface is also not allowed to contain operator overloads.
(4)It’s also not permitted to declare modifiers on the members in an interface definition. Interface members are always implicitly public, and they cannot be declared as virtual.Therefore, it is fine for implementing classes to declare access modifiers.
网友评论