Solved

Extension in .net

Posted on 2009-07-13
10
169 Views
Last Modified: 2013-11-08
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
0
Comment
Question by:KaranGupta
  • 5
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24837890
what extension is it talking about? file extension, ajax extentions? that question on its own is a bit ambiguos to me...
0
 

Author Comment

by:KaranGupta
ID: 24837896
Apart from ajax extension

is there any extension in .net
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24837899
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
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 24837904
0
 

Author Comment

by:KaranGupta
ID: 24837974
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
0
 

Author Comment

by:KaranGupta
ID: 24846311
Hi

Any updates on this
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24846536
>> if a function is passing 2 parameters then how we will call this function

What do you mean exactly ?


string s = "Hello Extension Methods";
string strReverse = s.Reverse (strReverse, 10);
 
public string Reverse(String strReverse, int MaxLength)
{
    ...
}

Open in new window

0
 

Author Comment

by:KaranGupta
ID: 24846548
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
0
 

Author Comment

by:KaranGupta
ID: 24866929
HI

ANy updates
0
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24867905
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C#.NET and microsoft certification. 3 40
VB.Net Report Printing Issue 3 34
Moving code from one TFS branch to another 3 25
DataTables + iCheck + pagination Issue 2 23
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question