What is delegate in C#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is delegate in C#?

A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance.-------From MSDN My understanding to delegate: It's a way of calling back a method. What confused me is: that if we can pass an object and its member methods through arguments, then why do we need the delegate? For the use of calling static method or skip constructor of calling object?

24th Jun 2022, 1:22 AM
Yasswecancn
Yasswecancn - avatar
1 Answer
- 1
A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance.
25th Jun 2022, 1:27 AM
CHONG ZI XU Moe
CHONG ZI XU Moe - avatar