1/55
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Delegate
A class in .NET that encapsulates a method.
Delegate
A reference type data type that holds a reference to a method.
Delegate
A class that can call any method as long as its signature matches.
delegate keyword
The keyword used in declaring a delegate on a class.
Signature
Must match between a delegate and the method it references.
Access modifier
The first item to identify when declaring a delegate.
Return type
The type specified when declaring a delegate, such as void, int, or string.
Delegate name
The desired name specified when declaring a delegate.
Parameters
The parameters specified inside the open and close parentheses of a delegate declaration.
Delegate declaration syntax
Delegate instantiation
The process of creating a delegate instance that refers to a method.
new keyword
The keyword used to instantiate a delegate in the example.
Delegate invocation
The process of invoking a referenced method through a delegate.
Referenced method
The method that a delegate references.
Parameters of a delegate
The parameters that should have the same count as the referenced method when referencing it.
Generic delegates
Delegates that are not bound to any specific type.
Generic delegate
A delegate that can reference a method that returns and takes parameters of different types.
Type parameter
The type represented by X in the generic delegate example.
Delegates and interfaces
Both include the declaration, but they have differences.
Delegates
They have no implementation; they are just safe callbacks and only have a declaration.
Interfaces
A class that implements this can implement all the methods associated with it.
Delegates
They can reference any method of a class that provides arguments and return types.
Interfaces
This allows extending some of the objects’ functionality.
Delegates
They are used if a class needs more than one implementation of the method.
Interfaces
They can implement a method only once.
Delegates
They are faster to execute but slower to get.
Interfaces
They are slower in executing but faster to get.
Event handling
In C#.NET, events are usually task initiators.
Event
This is a member of a class that is fired whenever a specific action takes place.
Event
This occurs when a specific action takes place.
Event handler
The method that is created and registered to an event and is automatically invoked when the event occurs.
Event handler
The methods that are invoked when an event occurs.
Method registration
This is done through delegates that specify the signature of a method registered for it.
Event declaration
Before declaring an event, a delegate to which the event is supposed to be associated should be declared first.
Event-associated delegate
The delegate to which an event is supposed to be associated.
Delegate in the event declaration
The delegate that contains two parameters and can reference methods that have the same count of parameters.
Parameter count
It can reference a method with the same count of parameters.
Event declaration
What is the next step after declaring the delegate?
public event delegate_name event_name
Event declaration syntax.
event keyword
The keyword used when declaring an event.
Event name
The preferred name given to an event when declaring it.
Delegate name
This is used in the event declaration.
Adding a delegate to an event
The process of registering a delegate with an event using the += operator.
+= operator
The operator used to add a delegate to an event.
Event subscription
The registration of a new subscription to an event.
event_name += delegate_instance
Event subscription syntax.
Event accessors
The two methods automatically generated by the compiler when the += operator is used with an event.
add accessor An event accessor used to register a new subscription to an event.
remove accessor An event accessor used to unregister the subscription to an event.
Property accessors The get and set accessors used with properties.
Event accessors
The add and remove accessors that are similar to the get and set accessors used with properties.
Unregistering a subscription
The process performed by using the remove accessor.
Registering a subscription
The process performed by using the add accessor.
add and remove
The two event accessors generated by the compiler.
Event accessor code
The code that can be used in add and remove to check some conditions before registering or unregistering the subscriber.
Subscriber
The method or delegate registered or unregistered through an event's add or remove accessor.