Pour in your posts. I'll start with a couple, let us see how much we can collect.
To provide inline event handlers like
button.Click += (sender,args) =>
{
};
To find items in a collection
var dogs= animals.Where(animal => animal.Type == "dog");
For iterating a collection, like
animals.ForEach(animal=>Console.WriteLine(animal.Name));
Let them come!!
Returning an custom object:
var dude = mySource.Select(x => new {Name = x.name, Surname = x.surname});
One line function
Func<int, int> multiply = x => x * 2;
int y = multiply(4);
Here's a slightly different one - you can use them (like this) to simulate the missing "infoof"/"nameof" operators in C# - i.e. so that instead of hard-coding to a property name as a string, you can use a lambda. This means that it is validated at compile time (which strings can't be).
There is obviously a performance cost to this, hence "just for fun", but interesting...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With