C# Anonymous Functions and Lambda Expressions


Anonymous Functions are functions that are defined inline. i.e On the fly. Before i go into explaining the concepts the easier way is to go through some code. Below is a small program which will search for a particular name in a List and if found, write to the console name found

The below code shows how to implement such a program without using Anonymous Functions.



The below code shows how to implement the same Program WITH using Anonymous Functions.


And we get the same output with more compact code using lambda expressions.


Result

Our Code is more compact and easier to read and maintain. 

Explanation:

So what's happening is that in our first Program we are calling a function from our string.find method. The function that we have defined separately. On line 19

var output=names.Find(SearchName);
 Ok so the above code uses a Predicate Delegate.

Types of Delegates

1) Action
2) Func

More on this in the next installment

Running Drupal in Docker

I will assume that you have already installed docker. If you haven't installed docker please visit https://www.docker.com/ to download a...