C# EventHandler 委托

来源:互联网 发布:网络推广培训 编辑:程序博客网 时间:2024/06/14 19:28
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace EventHandlerTest{    class Program    {        //委托        public delegate void EventHandler(string a);        //事件        public static event EventHandler SetCode;        static void Main(string[] args)        {            //注册            Program.SetCode += GetCode;            //触发            SetCode("触发");        }        public static void GetCode(string s)        {            Console.WriteLine(s);        }    }}

MSDN EventHandler 委托

0 0
原创粉丝点击