X hits on this document

1484 views

0 shares

0 downloads

0 comments

292 / 396

Chapter ‎18   Unsafe code

interface IBase { void F(int i); }

interface ILeft: IBase { new void F(int i); }

interface IRight: IBase { void G(); }

interface IDerived: ILeft, IRight {}

class A { void Test(IDerived d) { d.F(1);// Invokes ILeft.F ((IBase)d).F(1);// Invokes IBase.F ((ILeft)d).F(1);// Invokes ILeft.F ((IRight)d).F(1);// Invokes IBase.F } }

the IBase.F member is hidden by the ILeft.F member. The invocation d.F(1) thus selects ILeft.F, even though IBase.F appears to not be hidden in the access path that leads through IRight.

The intuitive rule for hiding in multiple-inheritance interfaces is simply this: If a member is hidden in any access path, it is hidden in all access paths. Because the access path from IDerived to ILeft to IBase hides IBase.F, the member is also hidden in the access path from IDerived to IRight to IBase.

13.3 Fully qualified interface member names

An interface member is sometimes referred to by its fully qualified name. The fully qualified name of an interface member consists of the name of the interface in which the member is declared, followed by a dot, followed by the name of the member. The fully qualified name of a member references the interface in which the member is declared. For example, given the declarations

interface IControl { void Paint(); }

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

the fully qualified name of Paint is IControl.Paint and the fully qualified name of SetText is ITextBox.SetText.

In the example above, it is not possible to refer to Paint as ITextBox.Paint.

When an interface is part of a namespace, the fully qualified name of an interface member includes the namespace name. For example

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

Document info
Document views1484
Page views1484
Page last viewedTue Jan 24 20:50:27 UTC 2017
Pages396
Paragraphs9401
Words133190

Comments