Anonymous Methods in C#
Why do we need Anonymous Methods in C#? In our Delegates in C# article, we discussed how to bind a delegate with a method. To bind a delegate with a method, first, we need to create an instance of the delegate and when we create the instance of the delegate, we need to pass the method name as a parameter to the delegate constructor, and it is the function the delegate will point to and when we invoke the delegate, this function which is pointed by the delegate is going to be executed. It is also possible that the delegates might be pointed to multiple functions and in that case, when we invoke the delegate instance, then all the functions which are pointed by the delegate are going to be executed. Example to Understand Delegate in C#: Before understanding the anonymous method, let us first see how we can use a delegate to execute the method. Why because to understand the Anonymous method, it is important to understand delegate because anonymous methods are used dele...