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.
This is a lambda expression that contains multiple parameters. In this case (as you are using the function to replace an event handler) they are equivalent to the object
and EventArgs
parameters.
Your code is equivalent to the below
app.InstallStateChanged += OnInstallStateChanged;
NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged;
/* ... */
private void OnInstallStateChanged(object s, EventArgs e)
{
UpdateUI();
}
private void OnNetworkAddressChanged(object s, EventArgs e)
{
UpdateNetworkIndicator();
}
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