Skip to main content
6 of 6
deleted 265 characters in body
Ed James
  • 1.3k
  • 1
  • 10
  • 14

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exist and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces. For a hierarchy of Types, extension methods provide a means to extend behaviour without having to open the entire hierarchy for modification.

However, extension methods are unable to access private implementation, so at the top of a hierarchy, if I need to encapsulate private implementation behind a public interface then an abstract class would be the only way.

Ed James
  • 1.3k
  • 1
  • 10
  • 14