What is extended method in c#

Answer Posted / ashish agrawal

Extension methods enable you to "add" methods to existing
types without creating a new derived type, recompiling, or
otherwise modifying the original type. Extension methods are
a special kind of static method, but they are called as if
they were instance methods on the extended type. For client
code written in C# and Visual Basic, there is no apparent
difference between calling an extension method and the
methods that are actually defined in a type.

class ExtensionMethods2
{

static void Main()
{
int[] ints = { 10, 45, 15, 39, 21, 26 };
var result = ints.OrderBy(g => g);
foreach (var i in result)
{
System.Console.Write(i + " ");
}
}
}
//Output: 10 15 21 26 39 45

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between write and writeline?

554


What are the different types of delegation?

519


Why do we need collections in c#?

551


Define multicast delegate in c#?

593


What framework is used for performance testing/load testing?

1571






How can you use abstract class and interface?

616


Can class inherit from struct c#?

617


Why c# is called type safe language?

537


What is predicate c#?

628


What is typeof c#?

603


Describe two uses of the “using” statement during the operation of c#?

624


What is Named parameter in C#?

632


Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?

644


Why do we use threads in c#?

611


What is void in c#?

633