Summary
In this chapter, I have introduced you to extension methods, including how to declare them, how to
call them, and also how the compiler implements them under the covers. Additionally, we saw how
they really are just syntactic sugar and don’t require any changes to the underlying runtime in order
to work. Extension methods can cause confusion when defined inappropriately, so we looked at
some caveats to avoid. I showed you how they can be used to create such useful things such as iter-
ators (IEnumerable<T> types) on containers that are not enumerable by default. Even for types that
do have enumerators, you can define enumerators that iterate in a custom way. As you’ll see in
Chapter 15, when they are combined with lambda expressions, extension ...