제목 : 이벤트 확장 : 매개변수도 있고 반환값도 있는 메서드 호출
    
    
        
            
                | 
                    글번호:
                 | 
                
                 | 
                
                    309
                 | 
            
            
                | 
                    작성자:
                 | 
                
                 | 
                
                    
                        레드플러스
                        
                        
                    
                 | 
            
            
                | 
                    작성일:
                 | 
                
                 | 
                
                    
                        2006/07/18 오후 7:43:00 
                    
                 | 
            
            
            
                | 
                    조회수:
                 | 
                
                 | 
                
                    
                        7082
                    
                 | 
            
            
        
     
 
    
	
	
    
	using System;
namespace 이벤트{
    public delegate int EventHandler(int a, int b);
    public class Su{
        public event EventHandler Calc;
        public int OnCalc(int a, int b){
            int result = 0;
            if (Calc != null){
                result = Calc(a, b);    
            }
            return result;
        }
        public static int Hap(int a, int b){
            return a + b;
        }
    }
    class 이벤트확장{
        static void Main(string[] args){
            //[1] 메서드
            Console.WriteLine( Su.Hap(3, 5) );
            //[2] 대리자
            EventHandler eh = new EventHandler(Su.Hap);
            Console.WriteLine( eh(3, 5) );            
            //[3] 이벤트
            Su su = new Su();
            su.Calc += new EventHandler(Su.Hap);
            Console.WriteLine(su.OnCalc(3, 5));
        }
    }
}