What happen when we create an extension method with the name with which an instance method already exists
Posted on 1/6/2008 6:23:10 AM
in #Asp.Net 3.X
Hi,
One of the interesting things that I have not yet mentioned about the Extension method is there naming convention. In dot net framework 3.5 there is not restriction on the naming convention of the extension methods.
What this means is that we can have two extension methods with the same name. In fact we can have an extension method with the same name as an instance method of the class.
So an extension method like ToString() can be added to the object although the same method already exists in the same class. The method call will be selected in the following order.
Instance method.
Extension method with the same namespace
Extension method outside the current namespace
Vikram
|
Posted on 1/6/2008 6:38:25 AM
Excellent, I was actually going to try this. Thanks for saving me some time.
|