1. ) What is Anonymous Methods?
Anonymous method allow you to handle an event rather having a separate event handler. Suppose you want to display some message to users at a click of a button ,ypu can handle it in a standard way with a delegate and event handler or you can also perform this action using anonymous method.
There are some points about anonymous method as given below:-
2. ) What are benifits of Anonymous Methods? Anonymous method allow you to handle an event rather having a separate event handler. Suppose you want to display some message to users at a click of a button ,ypu can handle it in a standard way with a delegate and event handler or you can also perform this action using anonymous method.
There are some points about anonymous method as given below:-
- Anonymous Methods helps to reduce the codes .
- No need to define any static event handlers in anonymous method.
Lambda Expression is the extension of the anonymous method.In .NET Framework 3.5 , a new syntax is introduce in anonymous method that is called Lambda expression. Lambda Expression is an anonymous function that can contain expression and statement to create delegates or expression tree types.It uses the Lambda operator (=>).
Ex.
(Input parameter) => expression;
The Left had side of the Lambda operator specifies the Expression or the statement.
- Here parentheses are optional if Lambda Expression has only one parameter.
- If Lambda Expression contains more than one parameter then parentheses and commas (') are required otherwise program will give error.
There are some benefits of Lambda Expression in Linq as given below:-
- The Lambda Expression allows you to declare your method code inline instead of with the delegate function.
- It has more concise syntax to achieve same goal.
- The Lambda Expression are very helpful in writing Linq query expression with a very compact and concise way.
- The Lambda Expression is almost similar to anonymous method which was introduced with .NET 2.0.
- The Lambda Expression provides a more concise and functional syntax for writing the anonymous method.
- There are no basic Difference between them.Means Lambda Expression is an anonymous function.
- In Lambda Expression ,syntax elements are not required,which is automatically managed by the compiler.
- Query Syntax
- Method Syntax
- Mixed Syntax
There are some quantifiers in Linq as given below:-
- All ( )
- Contains ( )
- Any ( )
- SequenceEqual()
There are some aggregate operators used in Linq as given below:-
- Aggregate
- Average
- Count
- LongCount
- Min
- Max
- Sum
- Join
- GroupJoin
- OrderBy
- OrderByDescending
- ThenBy
- ThenByDescending
- Reverse
0 comments:
Post a Comment