13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 20 InterfacesInherited public member declarations and inherited explicit interface member declarations participate in theinterface mapping process for re-implemented interfaces. [Example: For exampleinterface IMethods{void F();void G();void H();void I();}class Base: IMethods{void IMethods.F() {}void IMethods.G() {}public void H() {}public void I() {}}class Derived: Base, IMethods{public void F() {}void IMethods.H() {}}Here, the implementation of IMethods in Derived maps the interface methods onto Derived.F,Base.IMethods.G, Derived.IMethods.H, and Base.I. end example]When a class implements an interface, it implicitly also implements all of that interface’s base interfaces.Likewise, a re-implementation of an interface is also implicitly a re-implementation of all of the interface’s baseinterfaces. [Example: For exampleinterface IBase{void F();}interface IDerived: IBase{void G();}class C: IDerived{void IBase.F() {…}void IDerived.G() {…}}class D: C, IDerived{public void F() {…}public void G() {…}}Here, the re-implementation of IDerived also re-implements IBase, mapping IBase.F onto D.F. endexample]20.4.5 Abstract classes and interfacesLike a non-abstract class, an abstract class must provide implementations of all members of the interfaces that arelisted in the base class list of the class. However, an abstract class is permitted to map interface methods ontoabstract methods. [Example: For exampleinterface IMethods{void F();void G();}291

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!