Raise an event of a class from a different class in C#

后端 未结 12 895
庸人自扰
庸人自扰 2020-11-28 07:44

I have a class, EventContainer.cs, which contains an event, say:

public event EventHandler AfterSearch;

I have another class, EventRaiser.c

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 08:18

    Agree with Femaref -- and note this is an important difference between delegates and events (see for example this blog entry for an good discussion of this and other differences).

    Depending on what you want to achieve, you might be better off with a delegate.

提交回复
热议问题