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
Explain the difference between event and a delegate in c#?
What does f mean in c#?
What is the difference between private and protected in c#?
List down the access modifiers available in c#?
Can we customize the serialization process?
List down the reason behind the usage of c# language.
Difference between Value type & reference types ? and give the example in .Net?
Is for loop faster than foreach?
In a site to turn off cookies for one page which method is followed?
What is the console on a mac?
Why c# is called c sharp?
what is inheritance and an example in vb.net and c# of when you might use it?
What is int32?
What is list collection in c#?
What is msil in c#?