Looking at some source code, I found this operator
() => { }
From reading MSDN I now know it is the lambda operator, but what effect will it have on () going through { }? It is used as an argument to a class constructor.
It is an Action
(void, no parameters) delegate with a body that does nothing. Useful for when a non-null delegate is needed (perhaps to simplify callback or event invocation, as invoking on a null
is an error), but you have nothing specific to do.
It can be called empty delegate. It does nothing, but it is safe to call it without checking for null
s. Sort of placeholder.
I use it like this:
event Action SafeEvent = () => { };
event Action NullableEvent;
void Meth()
{
//Always ok
SafeEvent();
//Not safe
NullableEvent();
//Safe
if (NullableEvent != null)
NullableEvent();
}
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