I did go through some MSDN documentations. I found extension methods also documented there.
I didn’t understand, why these base class libraries have extension methods? when they could have been added to that particular class library itself?
what is the advantage? difference ?
Extension methods as name suggests extends the functionality or usability of the target type.
Correct use of extension methods can remove orthogonal clutter from the actual type definition/implementation (instead focusing of the core functionality of the type within type definition).
Take example of LINQ – by providing extension methods to
IEnumerable, it could target vast number of already published types (and vast number of types that may written in future); it has separated orthogonal concern such as querying the type from the actual type.