Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why extension methods in C# Class Libraries

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 ?

like image 626
dotNETbeginner Avatar asked Jan 03 '12 10:01

dotNETbeginner


1 Answers

Note, that many of the these methods operates on Interfaces, which is a perfectly legitimate excuse of using Extension Methods, even for Microsoft since interfaces themselves can't have any implementation of methods.

like image 50
Pauli Østerø Avatar answered Sep 28 '22 18:09

Pauli Østerø