Multicast delegate weird behavior in C#?

前端 未结 4 1068
春和景丽
春和景丽 2020-12-10 23:57

I have this simple event :

public class ClassA
{
    public event Func Ev;
    public int Do(string l)
    {
        return Ev(l);
    }
}
         


        
4条回答
  •  悲哀的现实
    2020-12-11 00:18

    Invoking a multicast non-void delegate returns the value of the last handler that was executed.

    You have very little control over who is first or last. It is a lousy system to use.

    That is why most events and delegates return void.

提交回复
热议问题