X hits on this document

1007 views

0 shares

0 downloads

0 comments

251 / 396

C# LANGUAGE SPECIFICATION

Events are declared using event-declarations:

event-declaration: attributesopt   event-modifiersopt   event   type   variable-declarators   ; attributesopt   event-modifiersopt   event   type   member-name   {   event-accessor-declarations   }

event-modifiers: event-modifier event-modifiers   event-modifier

event-modifier: new public protected internal private static virtual sealed override abstract extern

event-accessor-declarations: add-accessor-declaration   remove-accessor-declaration remove-accessor-declaration   add-accessor-declaration

add-accessor-declaration: attributesopt   add   block

remove-accessor-declaration: attributesopt   remove   block

An event-declaration may include a set of attributes (§‎17) and a valid combination of the four access modifiers (§‎10.2.3), the new (§‎10.2.2),  static (§‎10.5.2), virtual (§‎10.5.3), override (§‎10.5.4), sealed (§‎10.5.5), abstract (§‎10.5.6), and extern (§‎10.5.7) modifiers.

Event declarations are subject to the same rules as method declarations (§‎10.5) with regard to valid combinations of modifiers.

The type of an event declaration must be a delegate-type (§‎4.2), and that delegate-type must be at least as accessible as the event itself (§‎3.5.4).

An event declaration may include event-accessor-declarations. However, if it does not, for non-extern, non-abstract events, the compiler supplies them automatically (§‎10.7.1); for extern events, the accessors are provided externally.

An event declaration that omits event-accessor-declarations defines one or more events—one for each of the variable-declarators. The attributes and modifiers apply to all of the members declared by such an event-declaration.

It is a compile-time error for an event-declaration to include both the abstract modifier and brace-delimited event-accessor-declarations.

When an event declaration includes an extern modifier, the event is said to be an external event. Because an external event declaration provides no actual implementation, it is an error for it to include both the extern modifier and event-accessor-declarations.

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

Document info
Document views1007
Page views1007
Page last viewedFri Dec 09 14:12:15 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments