c#中的?.Invoke,即问号点Invoke

转自: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);
            }
        }

  

c#中的?.Invoke,即问号点Invoke

上一篇:美年旅游项目自记录Day06


下一篇:day06 首页文章排版