标签:style blog class c code java
public class UploadEnventcs { public event EventHandler CreateEvent; public delegate void CreateDele(object sender); public CreateDele cd; public void Upload() { if (CreateEvent != null) { Console.WriteLine("CreateEvent绑定的有事件"); CreateEvent(this, null); } if (cd != null) { Console.WriteLine("CreateDele绑定的有事件"); cd(this); } } }
调用
class Program { static void Main(string[] args) { UploadEnventcs ue = new UploadEnventcs(); ue.CreateEvent += ue_CreateEvent; ue.cd = new UploadEnventcs.CreateDele(CreateDelegate); ue.Upload(); } static void ue_CreateEvent(object sender, EventArgs e) { Console.WriteLine("已执行ue_CreateEvent"); } public static void CreateDelegate(object sender) { Console.WriteLine("已执行CreateDele委托"); } }
标签:style blog class c code java
原文地址:http://www.cnblogs.com/shikyoh/p/3738618.html