X hits on this document

769 views

0 shares

0 downloads

0 comments

220 / 396

Chapter ‎18   Unsafe code

new public void set_P(int value) { } }

class Test { static void Main() { B b = new B(); A a = b; Console.WriteLine(a.P); Console.WriteLine(b.P); Console.WriteLine(b.get_P()); } }

a class A defines a read-only property P, thus reserving signatures for get_P and set_P methods. A class B derives from A and hides both of these reserved signatures. The example produces the output:

123 123 456

10.2.7.2 Member names reserved for events

For an event E (§‎10.7) of delegate type T, the following signatures are reserved:

void add_E(T handler); void remove_E(T handler);

10.2.7.3 Member names reserved for indexers

For an indexer (§‎10.8) of type T with parameter-list L, the following signatures are reserved:

T get_Item(L); void set_Item(L, T value);

Both signatures are reserved, even if the indexer is read-only or write-only.

10.2.7.4 Member names reserved for destructors

For a class containing a destructor (§‎10.12), the following signature is reserved:

void Finalize();

10.3 Constants

A constant is a class member that represents a constant value: a value that can be computed at compile-time. A constant-declaration introduces one or more constants of a given type.

constant-declaration: attributesopt   constant-modifiersopt   const   type   constant-declarators   ;

constant-modifiers: constant-modifier constant-modifiers   constant-modifier

constant-modifier: new public protected internal private

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

Document info
Document views769
Page views769
Page last viewedSat Dec 03 04:44:53 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments