c# Event移除所有绑定,注销事件绑定

public delegate void d_ReadyToPrint(byte[] bytes);
public event d_ReadyToPrint ReadyToPrint;

public void ClearAllEvent()
{
if (ReadyToPrint == null) return;
Delegate[] dels = ReadyToPrint.GetInvocationList();
foreach (Delegate del in dels)
{
object delObj = del.GetType().GetProperty("Method").GetValue(del, null);
string funcName = (string)delObj.GetType().GetProperty("Name").GetValue(delObj, null);
Console.WriteLine(funcName);
ReadyToPrint -= del as d_ReadyToPrint;
}
}

上一篇:CSS外边距margin


下一篇:css行内元素设置margin和padding不生效(问题)