13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 17 ClassesAn event declaration that includes both the abstract and override modifiers specifies that the event isabstract and overrides a base event. The accessors of such an event are also abstract.Abstract event declarations are only permitted in abstract classes (§17.1.1.1).The accessors of an inherited virtual event can be overridden in a derived class by including an event declarationthat specifies an override modifier. This is known as an overriding event declaration. An overriding eventdeclaration does not declare a new event. Instead, it simply specializes the implementations of the accessors of anexisting virtual event.An overriding event declaration must specify the exact same accessibility modifiers, type, and name as theoverridden event.An overriding event declaration may include the sealed modifier. Use of this modifier prevents a derived classfrom further overriding the event. The accessors of a sealed event are also sealed.It is a compile-time error for an overriding event declaration to include a new modifier.Except for differences in declaration and invocation syntax, virtual, sealed, override, and abstract accessorsbehave exactly like virtual, sealed, override and abstract methods. Specifically, the rules described in §17.5.3,§17.5.4, §17.5.5, and §17.5.6 apply as if accessors were methods of a corresponding form. Each accessorcorresponds to a method with a single value parameter of the event type, a void return type, and the samemodifiers as the containing event.17.8 IndexersAn indexer is a member that enables an object to be indexed in the same way as an array. Indexers are declaredusing indexer-declarations:indexer-declaration:attributes opt indexer-modifiers opt indexer-declarator { accessor-declarations }indexer-modifiers:indexer-modifierindexer-modifiers indexer-modifierindexer-modifier:newpublicprotectedinternalprivatevirtualsealedoverrideabstractexternindexer-declarator:type this [ formal-parameter-list ]type interface-type . this [ formal-parameter-list ]An indexer-declaration may include a set of attributes (§24) and a valid combination of the four access modifiers(§17.2.3), the new (§17.2.2), virtual (§17.5.3), override (§17.5.4), sealed (§17.5.5), abstract (§17.5.6),and extern (§17.5.7) modifiers.Indexer declarations are subject to the same rules as method declarations (§17.5) with regard to validcombinations of modifiers, with the one exception being that the static modifier is not permitted on an indexerdeclaration.The modifiers virtual, override, and abstract are mutually exclusive except in one case. The abstractand override modifiers may be used together so that an abstract indexer can override a virtual one.251

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!