static void Main(string[] args) { CustomNotifier notifier = new CustomNotifier(); notifier.SomethingHappened += new EventHandler(MyHandler); //이벤트를 내가 만든 로직이 있는 메서드랑 연결 for (int i = 0; i < 100; i++) { notifier.DoSomething(i); } }
static void Main(string[] args) { Console.WriteLine("이벤트사용!"); CustomNotifier notifier = new CustomNotifier(); notifier.SomethingHappened += new EventHandler(MyHandler); //이벤트를 내가 만든 로직이 있는 메서드랑 연결 for (int i = 1; i <= 100; i++) { notifier.Dosomething(i); } }
static void Main(string[] args) { Console.WriteLine("이벤트 사용!"); CustomNotifier notifier = new CustomNotifier(); notifier.SomethingHAppened += new EventHandler(MyHandler);//이벤트를 내가 만든 로직이랑 연결 for (int i = 1; i < 100; i++) { notifier.DoSomething(i);//100 이하에서 3, 6, 9에 관련된 값들만 나타남 } }