Thursday, October 6, 2022
Homemvc interview questionsWhat are anonymous methods in c#

What are anonymous methods in c#

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 which is not a good 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 to write an extra line of code, in terms of creating a function.

When do we use the anonymous method?

Check the reading with and without the anonymous method, and 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.



Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments