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

How many types of interface are there in c#?

468


What is attribute c#?

432


What are the applications of c#?

466


Can list contain duplicates c#?

485


Can arraylist store different data types in c#?

468






Please explain value types and reference types used in c#?

470


Which string method is used for concatenation of two strings in c#?

469


What is a lambda expression in c#?

503


What is dataview c#?

463


Difference between directcast and ctype.

535


Can we inherit singleton class in c#?

461


What is an object and a class?

551


Is typeof c#?

530


In dynamic link library, which api is used for load library?

521


Give an example of a ctype.

555