Using extension methods, you can declare methods that appear to augment the public interface, or contract, of a type. At first glance, they may appear to provide a way to extend classes that are not meant to be extended. However, it’s very important to note that extension methods cannot break encapsulation. That’s because they’re not really instance methods at all and thus cannot crack the shell of encapsulation on the type they are extending.
KeywordsSugar Encapsulation Prefix
Unable to display preview. Download preview PDF.
- 5.Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Boston, MA: Addison-Wesley Professional, 1995), is cited in the references at the end of this book.Google Scholar