Lecture overview -- Keyboard shortcut: 'u'  Previous page: Events -- Keyboard shortcut: 'p'  Next page: Examples of events -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 13 : 20
Object-oriented Programming in C#
Operators, Delegates, and Events
Events in C#

From inside some class, an event is a variable of a delegate type.

From outside a class, it is only possible to add to or remove from an event.

Events are intended to provide notifications, typically in relation to graphical user interfaces.

  • Restrictions on events

    • An event can only be activated from within the class to which the event belongs

    • From outside the class it is only possible to add (with +=) or subtract (with -=) operations to an event.

      • It is not possible to 'reset' the event with an ordinary assignment

There exists a generic delegate EventHandler<TEVentArgs> which is intended to be used as the type of standard events in .NET