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
How many types of interface are there in c#?
What is attribute c#?
What are the applications of c#?
Can list contain duplicates c#?
Can arraylist store different data types in c#?
Please explain value types and reference types used in c#?
Which string method is used for concatenation of two strings in c#?
What is a lambda expression in c#?
What is dataview c#?
Difference between directcast and ctype.
Can we inherit singleton class in c#?
What is an object and a class?
Is typeof c#?
In dynamic link library, which api is used for load library?
Give an example of a ctype.