Text version of the video
http://csharp-video-tutorials.blogspot.com/2014/03/part-99-lambda-expression-in-c_23.html
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1
Slides
http://csharp-video-tutorials.blogspot.com/2014/03/part-99-lambda-expression-in-c.html
All C# Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-c-video-tutorial-for-beginners.html
All C# Slides
http://csharp-video-tutorials.blogspot.com/p/c.html
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists
In this video we will discuss, what lambda expressions are with an example. We will be working with the same example that we worked with in Part 98.
Anonymous methods and Lambda expressions are very similar. Anonymous methods were introduced in C# 2 and Lambda expressions in C# 3.
To find an employee with Id = 102, using anonymous method
Employee employee = listEmployees.Find(delegate(Employee Emp) { return Emp.ID == 102; });
To find an employee with Id = 102, using lambda expression
Employee employee = listEmployees.Find(Emp =] Emp.ID == 102);
You can also explicitly specify the Input type but not required
employee = listEmployees.Find((Employee Emp) =] Emp.ID == 102);
Notice that with a Lambda expression you don’t have to use the delegate keyword explicitly and you dont’t have to specify the input parameter type explicitly. The parameter type is inferred. Lambda expressions are more convenient to use than anonymous methods. Lambda expressions are particularly helpful for writing LINQ query expressions.
=] is called lambda operator and read as GOES TO.
In most of the cases Lambda expressions supersedes anonymous methods. To my knowledge, the only time I prefer to use anonymous methods over lambdas is, when we have to omit the parameter list when it’s not used within the body.
Anonymous methods allow the parameter list to be omitted entirely when it’s not used within the body, where as with lambda expressions this is not the case.
For example, with anonymous method notice that we have omitted the parameter list as we are not using them within the body
Button1.Click += delegate
{
MessageBox.Show(“Button Clicked”);
};
The above code can be rewritten using lambda expression as shown below. Notice that with lambda we cannot omit the parameter list.
Button1.Click += (eventSender, eventAgrs) =]
{
MessageBox.Show(“Button Clicked”);
};
You are Simply doing a Great Job Venkat, I watch your viedos over and over, Interview preparations means Kud Venkat Videos…. Simply Superb…….
Lambda expression=most stupid idea of programming language…
Nice tutorial. I always need a refresher on this topic and chaining linq operators
Thank you very much, i appretiate your video and effort π
Thx very much sir πͺ.
<3
Cheers man! Very helpful
Not helpful.
OMG
Thank you so very much for your very clear style, and for the effort you put forth in making these videos available. I have bookmarked your tutorial series and am eager to recommend them when ever I can!
Your explanation helped a lot
Hi Venkat ,
I like your videos on different concepts..
I would like to know from you that is there a good scope for a desktop windows application developer in the market . If we compare these developers with those of web (MVC) developers who will have more job opportunities…Also do a product based companies prefer windows application development?
public override bool CanRead => true;
what is the meaning of the above line. ?
Thanks sir ji.
I was looking for an expression of lambda. Several sites just confused me, but this was great.
Amazing tutorials. But hasnt anyone noticed that his voice sounds deeper along the videos .LOL He has the batman voice now
you are fabulous !!!
Thanks for clearing it π
What if you needed to convert a string array to a class list? How would that work?
very good