Complete the code to declare a delegate named MyDelegate that takes an int parameter.
public delegate [1] MyDelegate(int number);The delegate declaration requires the return type first. Here, void means the delegate method returns nothing.
Complete the code to instantiate the delegate with a method named PrintNumber.
MyDelegate del = new MyDelegate([1]);The delegate instance must be created with the exact method name that matches the delegate signature, here PrintNumber.
Fix the error in the delegate instantiation by completing the code.
MyDelegate del = [1] (PrintNumber);To instantiate a delegate, you must use the new MyDelegate keyword followed by the method name.
Fill both blanks to declare a delegate named Calculator that returns an int and takes two int parameters.
public delegate [1] Calculator([2] a, int b);
The delegate return type is int and the first parameter type is also int.
Fill all three blanks to instantiate a delegate named Calculator with a method named Add and invoke it with arguments 5 and 10.
Calculator calc = [1]([2]); int result = calc([3], 10);
You create a new delegate instance with new Calculator, pass the method Add, and invoke it with the first argument 5 and second argument 10.