Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an event named OnChange of type EventHandler.
C Sharp (C#)
public event [1] OnChange; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delegate' keyword instead of the event type.
Using 'event' keyword twice.
Using 'Action' without proper delegate signature.
✗ Incorrect
The correct syntax to declare an event uses the event type, here 'EventHandler'.
2fill in blank
mediumComplete the code to declare an event named DataReceived using a custom delegate DataHandler.
C Sharp (C#)
public delegate void DataHandler(string data);
public event [1] DataReceived; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'EventHandler' instead of the custom delegate.
Using 'Func' which is not a valid event delegate here.
Using 'Action' without declaring it.
✗ Incorrect
The event must be declared with the delegate type 'DataHandler' to match the custom delegate.
3fill in blank
hardFix the error in the event declaration by completing the code.
C Sharp (C#)
public [1] OnUpdate; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Placing 'delegate' keyword incorrectly.
Swapping order of 'event' and delegate type.
Including 'void' keyword in the event declaration.
✗ Incorrect
The correct syntax is 'event EventHandler' before the event name.
4fill in blank
hardFill both blanks to declare an event named ProcessCompleted using a delegate named ProcessHandler.
C Sharp (C#)
public [1] [2] ProcessCompleted;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delegate' keyword instead of 'event'.
Using 'void' instead of the delegate type.
Swapping the order of keywords.
✗ Incorrect
The correct syntax is 'event ProcessHandler ProcessCompleted;' to declare the event.
5fill in blank
hardFill all three blanks to declare an event named Alert using a delegate named AlertHandler with no parameters.
C Sharp (C#)
public [1] [2] [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'delegate' keyword in the declaration line.
Swapping delegate type and event name.
Omitting the 'event' keyword.
✗ Incorrect
The correct declaration is 'public event AlertHandler Alert;' for the event.