Delegates and Events (IT1811 Handout 1)

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

flashcard set

Earn XP

Description and Tags

Vocabulary-style flashcards covering key terms from the lecture notes on Delegates and Events.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

Delegate

A .NET class that encapsulates a method; a reference type that holds a reference to a method and can call methods with a matching signature.

2
New cards

Delegate signature

The return type and parameter list that must match the referenced method so the delegate can invoke it.

3
New cards

Declaring a delegate

Using the delegate keyword to declare a delegate in a class, specifying access modifier, return type, name, and parameters.

4
New cards

Instantiating a delegate

Creating a delegate instance using new or by assigning a method reference.

5
New cards

Invoking a delegate

Calling the method referenced by the delegate by invoking the delegate with appropriate arguments.

6
New cards

Generic delegate

A delegate not bound to a specific type, capable of referencing methods with different parameter and return types using a type parameter.

7
New cards

DisplayOutput

A generic delegate that takes a single parameter of type X and returns a value of type X.

8
New cards

Difference: delegates vs interfaces

Delegates are declarations with no implementation used as safe callbacks; interfaces declare methods that classes implement.

9
New cards

Event

A member of a class that fires when a specific action occurs and invokes its registered event handlers via delegates.

10
New cards

Event declaration

Declaring an event by declaring a delegate first, then using 'public event '.

11
New cards

Event subscription

Adding a handler to an event using the '+=' operator.

12
New cards

Event accessors

Compiler-generated add and remove methods for an event; can be customized with code in the accessors.

13
New cards

Add accessor

Code that runs when a new subscriber is added to an event.

14
New cards

Remove accessor

Code that runs when a subscriber is removed from an event.

15
New cards

Reference method

A method that is referenced by a delegate.

16
New cards

Parameter count matching

The delegate must have the same number of parameters as the referenced method.

17
New cards

Return type matching

The delegate's return type must match the referenced method's return type.

18
New cards

Static method reference

A static method can be referenced by a delegate.

19
New cards

Event handler

The method that is invoked in response to an event.