Extension method: Difference between revisions

Content deleted Content added
mNo edit summary
Problem: Wikified the paragraph.
Line 2:
One of the features of [[C-Sharp|C# 3.0]]
==Problem==
Normally, in a situation where it is necessary to add more functionality to a class - for instance a new method - it would simply be a matter of modifying the class' source code and recompiling the binaries with these new changes to make this effect. However, in some cases, especially when it comes to classes that are build-in into the .NET-framework or reside in third-party [[assemblies|.NET_assembly]], the programmer does not have access to the source code and is thus unable to change the behavior of the class directly. Heretofore, the programmer has been left with two other less intuitive options:
First let's consider the case we have a class, and we want to add extra function to it, so simply if we have the class code, we will edit that code and that's it, so what if this class is inside an assembly (dll) which we don't have the code, the solution will be one of two options,
# The first option is to inherit the class and then add the functionfunctionality.
# The second option is to write the method we want to extend inmake a new, separate class asand add a static method that takes an object of the class type and return a new object with the modification weof want,choice.
 
==Current Solution==