How does this code work?
app.InstallStateChanged += (s, e) => UpdateUI();
NetworkChange.NetworkAddressChanged +=
(s, e) => UpdateNetworkIndicator();
Can someone please unscramble this?
The code comes from an example used in a silverlight 4 OOB systems http://msdn.microsoft.com/en-us/library/dd833066(v=VS.95).aspx
UpdateNetworkIndicator does not return anything. UpdateUI does not return anything.
Both the UpdateUI() and UpdateNetworkIndicator() methods are custom event handler methods.
The += operator is attaching these event handlers to the events fired by the app and NetworkChange respectively.
The => denotes a lambda expression. The (s,e) are input parameters (in this case, the standard sender, event args) and the right of => is the statement or expression.
In this case, you could rewrite this as:
app.InstallStateChanged += UpdateUI;
NetworkChange.NetworkAddressChanged += UpdateNetworkIndicator;
and it should work just as well.