c# - Anonymous methods vs Extension method vs Lambda expression vs Linq -


Every time I go through an interview, I find it hard to define. Will some body please explain to me what is the difference between the two and how are they related? The interviewer is never satisfied with my answer.

Untitled Methods:

I say these are simple inline jobs.

Extension Methods:

These are methods that we can add on the fly without applying any interface.

Lambda expression:

I say this is used to query an object and I Let's start saying syntax.

link:

I say this is a query language that asks for any archive. And I start to say syntax.

I have been using these things for the past six months, but I am unable to properly define it.

Anonymous methods and lambda are very similar, since Lambda is a more powerful subtype of AIIMS using I LINQ Lumdas has to enable its functionality.

In C # v2, making a representative can be done by passing a code block as a parameter for a representative, such as MSDN in this example:

  Button1.Click + = delegate (System.Object o, System.EventArgs e) {System.Windows.Forms.MessageBox.Show ("Click!"); }  

Lambda inline, are anonymized methods that are the direct sub-classes of the appropriate parameters of Func or verb {/ code>. If a method takes a type of parameter foo then Func & lt; Int, string & gt; , you can call it like this:

  Foo X => "Number" + (string) x);  

and lambda x = & gt; "Number" + (string) x will be Func , will take an integer and produce the string when applicant is called on it.

LINQ is a great way to handle data, it has many ways, such as max , LINQ performs actions that can take custom functions to determine sorting or control. Pass a lambda (or, if you want, a reference to the designated function) and it will be used for operation by LINQ. Example:

  // List is a list & lt; String & gt; Console Limit (list max (str = & gt; str.Length));  

The maximum (the longest) string will be printed. After editing

edit : Extension methods are syntactic Chinese that help implement compiler. There are methods that are defined in a different place than a class / interface / strat, but it can be written as if they were a member of that thing. LINQ methods are IEnumerable & lt; T & gt; .

can be made more easily as extension methods

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -