Saturday, February 8, 2014

Introducing Extension Methods

Extending System Types
Writing extension methods
  1. Can live in any assembly
  2. With any namespace
  3. And any class name –typically
    • {Type}Extensions
    • {Feature}Extensions
Declaring extension methods
  • Type to extend in this argument

  • Static method in static class






Using extension method
  1. Reference extension method assembly
  2. Import extension method namespace
  3. Call the method on an instance


No comments:

Post a Comment