What are anonymous methods in c#

Anonymous methods in c#, Read more !!!

The base of the anonymous method is a delegate, so first, we dive deep to learn about what delegates are, and then we figure out the anonymous method.

Now in the above code for one line of code, we have created a separate function that could be a better practice overall. So here comes; the anonymous method came into the picture.

Here we point towards the function inline and invoke it.

So, anonymous methods help us write an extra line of code to create a function.

When do we use the anonymous method?

Check the reading with and without the anonymous method; you can see that the tick count is lesser when we use the anonymous method.

So, the anonymous method helps us in the improvement of performance.

Leave a Comment