What is extended method in c#

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


Please Help Members By Posting Answers For Below Questions

Explain the difference between event and a delegate in c#?

534


What does f mean in c#?

515


What is the difference between private and protected in c#?

500


List down the access modifiers available in c#?

485


Can we customize the serialization process?

526






List down the reason behind the usage of c# language.

652


Difference between Value type & reference types ? and give the example in .Net?

525


Is for loop faster than foreach?

533


In a site to turn off cookies for one page which method is followed?

511


What is the console on a mac?

476


Why c# is called c sharp?

467


what is inheritance and an example in vb.net and c# of when you might use it?

530


What is int32?

494


What is list collection in c#?

525


What is msil in c#?

555