I found this piece of code in one. htmlWeb.PreRequest does not appear to be an event handler because the
+ tab tab is not generating the required code, and its symbol in Intelsians tells me that it is a normal member variable
Please explain this syntax. Is this an event handler or something else? I've seen that
+ = is usually used to add event handlers, I searched Google for words like "How to add handler to event #", but no such code was found.
Please help me understand this code. I understand the meaning of this code, but not the syntax. Any other example would be appreciated.
HTML Web HTMLWeb = New HtmlWeb (); HtmlWeb.PreRequest + = Request = & gt; {Request.CookieContainer = New System.Net.CookieContainer (); Back true; }; Your code: HtmlWeb htmlWeb = new HtmlWeb (); HtmlWeb.PreRequest + = Request = & gt; {Request.CookieContainer = New System.Net.CookieContainer (); Back true; }; Really it is the opponent to:
bool PreRequest_EventHandler (HttpWebRequest request) {request.CookieContainer = New System.Net.CookieContainer (); Back true; } // ... HTML Web HTMLWeb = New HtmlWeb (); HtmlWeb.PreRequest + = PreRequest_EventHandler; The main difference is that it uses instead of declaring a different method as it has been said that the written MSDN Artistic Lambda syntax has the following forms:
(input parameter) = & gt; Expression Then enter request => in your code. Input parameter is left bracket because there is only one parameter. If there are two or more, then it is (x, y) = & gt; ... .
No comments:
Post a Comment