c# - How does addition assignment operator behave -
how addition assignment operator behaves here -
btn.click += delegate(object sender, eventargs e)
it adds event handler event click
. when click
event raised handlers method added called.
for example:
void btnclickhandler1(object sender, eventargs e) { messagebox.show("btnclickhandler1"); } void btnclickhandler2(object sender, eventargs e) { messagebox.show("btnclickhandler2"); }
and add these methods click event this:
btn.click += btnclickhandler1 btn.click += btnclickhandler2
when button clicked methods called in order added them, message box be:
btnclickhandler1 btnclickhandler2
if want specific info += operator, msdn says:
the += operator used specify method called in response event; such methods called event handlers. use of += operator in context referred subscribing event.
for more info at:
https://msdn.microsoft.com/en-us/library/edzehd2t%28v=vs.110%29.aspx
Comments
Post a Comment