namespace ConsoleApp5
{
class Program
{
public delegate void ButtonEvent();
public static event ButtonEvent evtClick; //이벤트 델리게이트 객체
public static void onClick() {
evtClick();
}
public static void MyHandler() {
Console.WriteLine("버튼 클릭 처리기 수행");
}
static void Main(string[] args)
{
evtClick += new ButtonEvent(MyHandler);
onClick();
}
}
}
using System.Windows.Forms;
namespace ConsoleApp9
{
public class FormEvent : Form {
public FormEvent() {
this.Click += new EventHandler(ClickEvent);
}
private void ClickEvent(object sender, EventArgs e){
MessageBox.Show("마우스 클릭 이벤트를 처리합니다.");
}
}
class Program
{
static void Main(string[] args)
{
Application.Run(new FormEvent());
}
}
}