본문으로 바로가기

C# interface 안에서 Delegate 선언

category 개발언어/C# 2017. 6. 14. 10:44

How to add a delegate to an interface C#

interface내에서 delegate를 선언하면 Error가 발생한다 
public interface IMyInterface
{       
  public delegate void UpdateStatusEventHandler(string status);
  public delegate void StartedEventHandler();
UpdateStatusEventHandler StatusUpdated {get; set;} StartedEventHandler Started {get; set;} }
이때는 interface 바깥부분에 delegate를 선언하면 된다
public delegate void UpdateStatusEventHandler(string status);
public delegate void StartedEventHandler();
public interface IMyInterface
{       
  UpdateStatusEventHandler StatusUpdated {get; set;}    
  StartedEventHandler Started {get; set;}
}