X hits on this document

930 views

0 shares

0 downloads

0 comments

297 / 396

C# LANGUAGE SPECIFICATION

interface IForm { void Paint(); }

class Page: IControl, IForm { public void Paint() {...} }

Here, the Paint methods of both IControl and IForm are mapped onto the Paint method in Page. It is of course also possible to have separate explicit interface member implementations for the two methods.

If a class or struct implements an interface that contains hidden members, then some members must necessarily be implemented through explicit interface member implementations. For example

interface IBase { int P { get; } }

interface IDerived: IBase { new int P(); }

An implementation of this interface would require at least one explicit interface member implementation, and would take one of the following forms

class C: IDerived { int IBase.P { get {...} }

int IDerived.P() {...} }

class C: IDerived { public int P { get {...} }

int IDerived.P() {...} }

class C: IDerived { int IBase.P { get {...} }

public int P() {...} }

When a class implements multiple interfaces that have the same base interface, there can be only one implementation of the base interface. In the example

interface IControl { void Paint(); }

interface ITextBox: IControl { void SetText(string text); }

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

Document info
Document views930
Page views930
Page last viewedWed Dec 07 18:44:43 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments