0
0
C Sharp (C#)programming~10 mins

Event declaration syntax in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AEventHandler
Bdelegate
Cevent
DAction
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delegate' keyword instead of the event type.
Using 'event' keyword twice.
Using 'Action' without proper delegate signature.
2fill in blank
medium

Complete 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'
AFunc<string>
BEventHandler
CAction<string>
DDataHandler
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.
3fill in blank
hard

Fix 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'
AEventHandler event
Bvoid event EventHandler
Cevent EventHandler
Ddelegate void EventHandler()
Attempts:
3 left
💡 Hint
Common Mistakes
Placing 'delegate' keyword incorrectly.
Swapping order of 'event' and delegate type.
Including 'void' keyword in the event declaration.
4fill in blank
hard

Fill 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'
Aevent
Bdelegate
CProcessHandler
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delegate' keyword instead of 'event'.
Using 'void' instead of the delegate type.
Swapping the order of keywords.
5fill in blank
hard

Fill 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'
Aevent
BAlertHandler
CAlert
Ddelegate
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'delegate' keyword in the declaration line.
Swapping delegate type and event name.
Omitting the 'event' keyword.