Introducing Extension Methods
Extending System Types
Writing extension methods
- Can live in any assembly
- With any namespace
- 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
- Reference extension method assembly
- Import extension method namespace
- Call the method on an instance
No comments:
Post a Comment