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
What is difference between write and writeline?
What are the different types of delegation?
Why do we need collections in c#?
Define multicast delegate in c#?
What framework is used for performance testing/load testing?
How can you use abstract class and interface?
Can class inherit from struct c#?
Why c# is called type safe language?
What is predicate c#?
What is typeof c#?
Describe two uses of the “using” statement during the operation of c#?
What is Named parameter in C#?
Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?
Why do we use threads in c#?
What is void in c#?