Difference in invoking through Delegates and Events C#

后端 未结 5 897
天命终不由人
天命终不由人 2021-01-13 22:11

What is the difference?

Using Delegate

public delegate void TestDelegate();
public TestDelegate delObj = SomeMethod;

public void S         


        
5条回答
  •  执笔经年
    2021-01-13 22:59

    It's effectively a property wrapper around the event.

    The main difference is that you can't invoke/raise the event from outside the class, whereas you can invoke the public delegate.

    Chaining (+=) is no different for delegates and events.

提交回复
热议问题