+= operator with Events

后端 未结 6 960
离开以前
离开以前 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:27

    In this case method foo_MyEvent will fire whene that event is called (so you subscribe to the event in line 4)

提交回复
热议问题