This is a lambda expression.
I assume that the SetLocatorProvider method has such a signature as:
SetLocatorProvider( Func<IServiceLocator> callback ):
Now you need to provide such a callback. There are three options:
Use the method (always running):
private IServiceLocator GetServiceLocator() { } ServiceLocator.SetLocatorProvider( GetServiceLocator() );
Use delegate (C # 2.0 required):
ServiceLocator.SetLocatorProvider( delegate {
Use lambda (C # 3.0 required):
This is the code you see ...
Since there is no argument ( Func<IServiceLocator> has only a return value), you indicate this with () :
ServiceLocator.SetLocatorProvider( () => { } );
it can be translated into
ServiceLocator.SetLocatorProvider( () => );
Perhaps you want to read this question + answer .
source share