What is the primary purpose of delegates in C#?

  1. Data storage
  2. String manipulation
  3. Memory allocation
  4. Type-safe function pointers

Explanation

Delegates are type-safe function pointers that can hold references to both static and instance methods. They enable callbacks, event handling, and functional programming patterns.