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
Can we set image Source dynamically using C# in WPF application?
What is a .aspx file?
Is it possible to have different access modifiers on the get/set methods of a property?
If c# destructors are so different to c++ destructors, why did ms use the same syntax?
What are the advantages of using c#?
Is c# the same as d flat?
Please write a program to display “welcome to bestinterviewquestion.com” in c#?
What is disco?
Explain how to add controls dynamically to the form using c#.net.
Explain About .Net remoting
What is unrecognized escape sequence in c#?
Can abstract class have parameterized constructor?
Which compiler switch creates an xml file from xml comments in the files in an assembly?
What is reference c#?
Define a manifest in .net?