Initiating a delegate using anonymous functions

In a situation where creating new methods can be classed as overhead, C# allows us to initiate a delegate and specify a code block. The delegate will process this code block when it is invoked. This is the method that's used in C# 2.0 to invoke delegates. They are also known as anonymous methods.

An expression or a statement that's defined inline instead of a delegate type is known as an anonymous function.

There are two types of anonymous function:

  • Lambda expressions
  • Anonymous methods

We will look at these two types of functions in the upcoming subsections. However, before we move on, we should also understand one new operator, called the Lambda operator. This is used to represent Lambda expressions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.4