Solved

Extension in .net

Posted on 2009-07-13
10
167 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

14 Experts available now in Live!

Get 1:1 Help Now