Is this a better way to fire/invoke events without a null check in C#?

后端 未结 4 726
庸人自扰
庸人自扰 2021-02-05 19:05

Most code I have seen uses the following way to declare and invoke event firing:

public class MyExample
{
    public event Action MyEvent; // could be an event E         


        
4条回答
  •  梦谈多话
    2021-02-05 19:46

    The best tradeoff I've seen for simplifying event firing is the addition of an extension method. See Raising C# events with an extension method - is it bad?.

提交回复
热议问题