Difficulty: Easy
Correct Answer: 1, 3 and 5 only
Explanation:
Introduction / Context:
C# delegates are type-safe function pointers. The compiler generates a sealed class behind the scenes for each delegate type. Understanding this generation helps reason about compatibility and invocation.
Given Data / Assumptions:
Concept / Approach:
Declaring a delegate produces a class with the same name that derives from MulticastDelegate. Methods assigned to that delegate must be signature-compatible (parameter list and return type). Delegates can reference static or instance methods. The generated delegate type exposes a constructor that takes the target (object for instance methods or null for static) and a method pointer, and it provides an Invoke method matching the delegate signature.
Step-by-Step Solution:
Verification / Alternative check:
Use reflection at runtime (typeof(del)) to see its BaseType (MulticastDelegate) and methods (Invoke, BeginInvoke/EndInvoke in older patterns).
Why Other Options Are Wrong:
Common Pitfalls:
Assuming any method can be assigned to a delegate regardless of signature; in C#, type safety is enforced.
Final Answer:
1, 3 and 5 only
Discussion & Comments