KaranGupta
asked on
Extension in .net
Hi
I have read this question in an interview site
What is the extension in .net
Can you tell me the white papers from where I can read it
I have read this question in an interview site
What is the extension in .net
Can you tell me the white papers from where I can read it
what extension is it talking about? file extension, ajax extentions? that question on its own is a bit ambiguos to me...
ASKER
Apart from ajax extension
is there any extension in .net
is there any extension in .net
Extension methods are a great new way of adding functionality to an existing type even a type you dont have the source code to modify that type. This article explains extension methods and provides clear examples along with pros and cons.
http://www.eggheadcafe.com/tutorials/aspnet/ce4969c5-b20a-42b4-82cf-3344eff69311/c-net-extension-methods.aspx
http://www.eggheadcafe.com/tutorials/aspnet/ce4969c5-b20a-42b4-82cf-3344eff69311/c-net-extension-methods.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I was studying it
http://www.dotnetfunda.com/articles/article445-extension-method-net-35-and-above.aspx
but there is a query
if a function is passing 2 parameters then how we will call this function
I was studying it
http://www.dotnetfunda.com/articles/article445-extension-method-net-35-and-above.aspx
but there is a query
if a function is passing 2 parameters then how we will call this function
ASKER
Hi
Any updates on this
Any updates on this
>> if a function is passing 2 parameters then how we will call this function
What do you mean exactly ?
What do you mean exactly ?
string s = "Hello Extension Methods";
string strReverse = s.Reverse (strReverse, 10);
public string Reverse(String strReverse, int MaxLength)
{
...
}
ASKER
Hi
I got my answer, but one more thing I want to ask is,
where is this statement justified
Extension method allows you to add new method to the existing class without modifying the code, recompiling or modifying the original code.
because we can attain the same result by using function overload.
What additional benefit do the developers have for using this function
I got my answer, but one more thing I want to ask is,
where is this statement justified
Extension method allows you to add new method to the existing class without modifying the code, recompiling or modifying the original code.
because we can attain the same result by using function overload.
What additional benefit do the developers have for using this function
ASKER
HI
ANy updates
ANy updates
you should really assign the points to this question and open a new one. But...
Overloading is different. Overloading allows you to create the same method name with different parameters e.g
public void DoSomething() { }
public void DoSomething(int aParameter) {}
etc....
Extension methods allow to to add methods to existing classes without having access to that classes source code. e.g you can add methods to the string object which is a build in class in the .net framework.
Overloading & Extensions are not the same.
Overloading is different. Overloading allows you to create the same method name with different parameters e.g
public void DoSomething() { }
public void DoSomething(int aParameter) {}
etc....
Extension methods allow to to add methods to existing classes without having access to that classes source code. e.g you can add methods to the string object which is a build in class in the .net framework.
Overloading & Extensions are not the same.