转自:https://hovertree.com/h/bjag/4dmf8x0u.htm
public delegate void OperateSuccessHanlder(string fileName); //创建委托 public event OperateSuccessHanlder OperateSuccess; //UCPictureAdd.ascx.cs中的代码 void OnOperateSuccess(string fileName) { OperateSuccess?.Invoke(fileName); }
上面代码等价于:
public delegate void OperateSuccessHanlder(string fileName); //创建委托 public event OperateSuccessHanlder OperateSuccess; //UCPictureAdd.ascx.cs中的代码 void OnOperateSuccess(string fileName) { if(OperateSuccess!=null) { OperateSuccess(fileName); } }