Delegate | Interface |
---|---|
We can define multiple methods by using delegate. | Interface defines only a single method. |
No need to implement multiple times. | Need to implement the interface multiple times. |
Fastest to call at runtime when we know all the parameter types. | Well designed interfaces are allowed for generic uses which are very faster than delegate’s DynamicInvoke . |
Recommended for multi use cases as it is more flexible than interface. | Very useful and faster for single use cases. |
Allows the use of anonymous delegates | Anonymous compile-time support is not possible in interfaces. |
Multicast is supported. | Interface doesn’t support multicast. |
Faster to execute. | Slower than delegates to execute. |
Slower to get. | Faster to get as they don’t allocate the new objects. |
Differences between Delegates and Interfaces
Tagged .Net, Interview Questions and Answers, OOPs. Bookmark the permalink.