Complete the code to declare a delegate named MyDelegate.
public delegate void [1]();The delegate is declared with the name MyDelegate to match the usage later.
Complete the code to add method1 to the multicast delegate.
MyDelegate d = method1; d [1]= method2;+ instead of +=.-= which removes a method.The += operator adds a method to the invocation list of the multicast delegate.
Fix the error in the code to invoke the multicast delegate safely.
if ([1] != null) d();
Before invoking a delegate, check if the delegate variable d is not null to avoid exceptions.
Fill both blanks to remove method2 from the multicast delegate and invoke it.
d [1]= method2; if (d [2] null) d();
+= instead of -= to remove a method.d == null instead of d != null.Use -= to remove a method from the delegate. Then check if d != null before invoking.
Fill all three blanks to create a multicast delegate, add two methods, and invoke it safely.
MyDelegate d = method1; d [1]= method2; if (d [2] null) d[3]();
+=.Use += to add methods, check d != null before invoking, and call the delegate with ().