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 icomparer in c#?
What is executenonquery c#?
How does the lifecycle of Windows services differ from Standard EXE?
What is difference between gridview and form view?
What is gridview c#?
Explain the difference between Metadata and Manifest
What is entity framework in c#?
Explain the functionalities of satellite assembly?
What are the return types in c#?
Is stringbuilder better than string?
State the top.NET class that everything is derived from?
Explain the use of Mutex in C#?
User's session is explicitly killed by which method ?
What is the difference between final finally and finalize in c#?
Explain the role of Garbage collector and its generations?