Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Clarification using "=>"

Tags:

c#

lambda

Can anybody please tell me what is happening in below code in simple English, specifically around the usage of => and += symbols:

var ls = new LibraryServiceClient(AppSettings.Get("LibraryServiceBaseAddress"), 
                                  SessionId, App.Id, _user.UUID);
ls.MakingRequest += (s, e) =>
{
    LogStash.LogDebug("Library Service | Before making request  : {0}",
    DateTime.UtcNow.ToString("HH:mm:ss.fff"));
};
like image 535
Asif Avatar asked Dec 05 '22 20:12

Asif


1 Answers

You assign a new delegate to the event:

ls.MakingRequest +=

You create a lambda expression, a function having two parameters, s and e:

 (s, e) =>

Where the action of the lambda expression is:

{ LogStash.LogDebug("Library Service | Before making request  : {0}", DateTime.UtcNow.ToString("HH:mm:ss.fff"));
like image 191
Patrick Hofman Avatar answered Dec 21 '22 22:12

Patrick Hofman