You may get confused about this topic PIN Extension Method. PIN is a collection of three IEnumerable extension methods.
PIN stands for
- PreviousItem
- IndexOfCurrentItem
- NextItem
These three extensions methods can be accessed on any IEnumerable type of collections.
Short introduction of Extension Methods:
An extension method is a special kind of static method that allows you to add new methods to existing types without creating derived types. The extension methods are called as if they were instance methods from the extended type. For example: x is an object from int class and we called it as an instance method in int class.
Extension methods allow existing classes to be extended without relying on inheritance or having to change the class's source code. This means that if you want to add some methods into the existing String class you can do it quite easily.
Considerations while creating Extension methods:
- Extension methods cannot be used to override existing methods
- An extension method with the same name and signature as an instance method will not be called
- The concept of extension methods cannot be applied to fields, properties or events
- Use extension methods sparingly...overuse can be a bad thing!
Why PIN:
You could have asked these questions in your past or you may have now...
- How to get the Previous item in a collection in a foreach loop
- How to get the Index of the current item of a collection in a foreach loop
- How to get the Next item in a collection in a foreach loop









Join the conversation! Your thoughts help the community grow.