How to add a delegate to an interface C#

前端 未结 6 1769
无人及你
无人及你 2021-01-30 07:42

I need to have some delegates in my class.

I\'d like to use the interface to \"remind\" me to set these delegates.

How to?

My class look like this:

6条回答
  •  春和景丽
    2021-01-30 08:47

    Just expose the delegate as a property

    public delegate void UpdateStatusEventHandler(string status);
    public delegate void StartedEventHandler();
    
    public interface IMyInterface
    {       
        UpdateStatusEventHandler StatusUpdated {get; set;}    
        StartedEventHandler Started {get; set;}
    }
    

提交回复
热议问题