Solved

Extension in .net

Posted on 2009-07-13
10
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

726 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