Comparison of Usage of Delegate and Interface ?

Use a delegate when:
  1. An eventing design pattern is used. • It is desirable to encapsulate a static method.
  2. The caller has no need access other properties, methods, or interfaces on the object implementing the method.
  3. Easy composition is desired
  4. A class may need more than one implementation of the method
Use an interface when:
  1. There are a group of related methods that may be called.
  2. A class only needs one implementation of the method.
  3. The class using the interface will want to cast that interface to other interface or class types.
  4. The method being implemented is linked to the type or identity of the class: for example, comparison methods.

No comments:

Popular Posts