What is extended method in c#

Answers were Sorted based on User's Feedback



What is extended method in c#..

Answer / 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

What is extended method in c#..

Answer / ratheesh

The most common extension methods are the LINQ standard query operators that add query functionality to the existing System.Collections.IEnumerable and System.

Is This Answer Correct ?    2 Yes 0 No

What is extended method in c#..

Answer / aniket

small information : extension methods are nothing but visitor design pattern.

http://www.codeproject.com/Articles/34209/Extension-Methods-in-C

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Why do we use delegates in c#?

0 Answers  


What is an assembly qualified name? Is it a filename? How is it different?

0 Answers  


Is for loop faster than foreach?

0 Answers  


What is the use of generics in c#?

0 Answers  


What is tpl in c#?

0 Answers  






What is delegates in c#?

0 Answers  


Assignment # 1 Print the pattern given below using single printf statement XX XX XX XX XX XX X X X X XX XX XX XX XX XX Assignment # 2 Print the pattern given below using single printf statement (please do NOT use the string function below) 0 909 89098 7890987 678909876 56789098765 4567890987654 345678909876543 23456789098765432 1234567890987654321

3 Answers   Wipro,


What are the advantages of using c#?

0 Answers  


Can you specify an access modifier for an enumeration?

0 Answers  


What is difference between method overriding and method overloading?

0 Answers  


What are events in C#?

0 Answers   CDC,


What are the applications of c#?

0 Answers  


Categories