Solved

Extension in .net

Posted on 2009-07-13
10
168 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Definitions and default visual studio colors 5 58
Help with solving error related to resources file 4 35
Resolve Dependency Issues 4 41
C# Single Form 8 26
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now