X hits on this document

776 views

0 shares

0 downloads

0 comments

300 / 396

Chapter ‎18   Unsafe code

class TextBox: Control { protected override void PaintControl() {...} }

Here, classes derived from Control can specialize the implementation of IControl.Paint by overriding the PaintControl method.

13.4.4 Interface re-implementation

A class that inherits an interface implementation is permitted to re-implement the interface by including it in the base class list.

A re-implementation of an interface follows exactly the same interface mapping rules as an initial implementation of an interface. Thus, the inherited interface mapping has no effect whatsoever on the interface mapping established for the re-implementation of the interface. For example, in the declarations

interface IControl { void Paint(); }

class Control: IControl { void IControl.Paint() {...} }

class MyControl: Control, IControl { public void Paint() {} }

the fact that Control maps IControl.Paint onto Control.IControl.Paint doesn’t affect the re-implementation in MyControl, which maps IControl.Paint onto MyControl.Paint.

Inherited public member declarations and inherited explicit interface member declarations participate in the interface mapping process for re-implemented interfaces. For example

interface 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() {} }

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

Document info
Document views776
Page views776
Page last viewedSat Dec 03 07:53:18 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments