Sunday, July 12, 2009

Delegates vs Interfaces in C# 2.0?

There is an explanation by Microsoft when to choose delegates n when to choose interfaces at the address below:





http://msdn2.microsoft.com/en-us/library...





I wonder why there should be such a comparison at all. Aren't these things two different concepts with different capabilities?

Delegates vs Interfaces in C# 2.0?
They are compared because in both cases, the delegate or the interface reference can be used for any object without having a knowledge of the class. It means you can use a delegate for several methods of even several classes as long as they fit the signature of the delegate. The same explanation applies to interface.
Reply:Yep they are very different. A Delegate is place to store a fuction you will invoke later.


An Interface is a definition of some functions.


No comments:

Post a Comment