Delegates, Anonymous Method, and Lambda Expression in C#
Hello everybody, I am again here with my new blog which is based on Delegates, Lambda expression in C and anonymous method. As I have experience in this section and it’s also quite important to know the details related to topic for you guys so I think it will be better to give information in details. So let’s start in briefly.
Delegates are mostly used in LINQ, .NET v 3.5, events, ASP.NET and other sector. In this blog, I will give you a brief idea about delegates which is based on etymologies, like Lambda Expression and Anonymous method. If I am going to discuss all the things in details, then this blog will be very large, so I will make another blog for it. Now In this blog you will get a complete idea on three key concepts like:
- Anonymous Method
- Lambda expression
Let’s discuss separately each section
This is a part of the C# since of its 1.0 version released and this is a delegate holds to a process. Delegates normally of two types one is single cast and the other one is Multicast. The delegate is that which represents references to various methods with a particular parameter which is the return type. This is used to pass methods as arguments to other methods.
- Anonymous method:
This is a special kind of inline code which is used when you expect any delegate type. Microsoft introduced this anonymous method in 2003 in C # 2.0 versions. In this method you have to specify the return type. It is contingent from the return statement inside the method body.
- Lambda Expression:
This is an anonymous function which is normally used to generate delegates in LINQ. This is a method you can define without declaration. Overall, this is a shorthand which permits you to express a method in a particular place you are going to use it. In 2007, Microsoft introduced this expression in 3.0 versions of C#. Many developers are getting confused with this anonymous method because it omits the parameter.
So this is all about these above three concepts. I will make another blog for you guys regarding delegates in which you will get more details ideas. So if you have confusion you can let me know under the comment section I will try my best to clear your doubts. For more information you can visit www.cpd-india.com. CPD Technologies Block C 9/8, Sector – 7, Rohini, Delhi – 110085, India Landmark: Near Rohini East Metro Station, Opposite Metro Pillar No-397. For free demo class you can call at-011-65164822/91-8860352748. For any suggestion free feels to email at firstname.lastname@example.org.