+= operator with Events

后端 未结 6 961
离开以前
离开以前 2020-11-28 09:50
public void Bar()
{
    Foo foo = new Foo();
    **foo.MyEvent += foo_MyEvent;**
    foo.FireEvent();        
}

void foo_MyEvent(object sender, EventArgs e)
{
    (         


        
6条回答
  •  甜味超标
    2020-11-28 10:26

    It add's handler to an event. It means that method on the right side of the operator will be invoked when the event will be risen.

提交回复
热议问题