X hits on this document

779 views

0 shares

0 downloads

0 comments

301 / 396

C# LANGUAGE SPECIFICATION

Here, the implementation of IMethods in Derived maps the interface methods onto Derived.F, Base.IMethods.G, Derived.IMethods.H, and Base.I.

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 base interfaces. For example

interface 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.

13.4.5 Abstract classes and interfaces

Like a non-abstract class, an abstract class must provide implementations of all members of the interfaces that are listed in the base class list of the class. However, an abstract class is permitted to map interface methods onto abstract methods. For example

interface IMethods { void F(); void G(); }

abstract class C: IMethods { public abstract void F(); public abstract void G(); }

Here, the implementation of IMethods maps F and G onto abstract methods, which must be overridden in non-abstract classes that derive from C.

Note that explicit interface member implementations cannot be abstract, but explicit interface member implementations are of course permitted to call abstract methods. For example

interface IMethods { void F(); void G(); }

288Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views779
Page views779
Page last viewedSat Dec 03 11:42:48 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments