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
Define parsing? Explain how to parse a datetime string?
What's the c# syntax to catch any possible exception?
List down the differences between public, static and void keywords?
What is default boolean value in c#?
What is the difference between a method and a property?
What is the difference between add and addrange in c#?
In a C# class we have a SortedList member m_addinProjects
we want to provide an iterator to allow the consumer of
this class access to the items in the collection. Please
provide an iterator method for the AnalyzeAddinsDLL class
below and an example of how it would be used.
namespace AnalyzeAddinsDLL
{
public class AllAddInProjects
{
private SortedList
Which compiler switch creates an xml file from xml comments in the files in an assembly?
What is an indexer in c#?
Explain About sn.exe
When was c# created?
Why is c# better than java?
How to use nullable types in .net?
Name which controls do not have events?
What is use of console?