제목 : 이벤트를사용한짝수의합.cs
    
    
        
            
                | 
                    글번호:
                 | 
                
                 | 
                
                    299
                 | 
            
            
                | 
                    작성자:
                 | 
                
                 | 
                
                    
                        레드플러스
                        
                        
                    
                 | 
            
            
                | 
                    작성일:
                 | 
                
                 | 
                
                    
                        2005/07/19 오전 9:52:00 
                    
                 | 
            
            
            
                | 
                    조회수:
                 | 
                
                 | 
                
                    
                        7099
                    
                 | 
            
            
        
     
 
    
	
	
    
	using System;
namespace 이벤트를사용한짝수의합{
    public class JavaScript{
        public static void Calculate(){
            int intSum = 0;
            for(int i = 1;i <= 100;i++){
                if(i % 2 == 0){
                    intSum += i;
                }
            }
            Console.WriteLine(intSum);
        }
    }
    //[1]
    public delegate void EventHandler();
    public class Input{
        //[2] 
        public event EventHandler Click;
        //[3] 
        public void OnClick(){
            if(Click != null){
                Click();
            }
        }
        private string _Type;
        public string Type{
            get { return _Type; }
            set { _Type = value; }
        }
        private string _Value;
        public string Value{
            get { return _Value; }
            set { _Value = value; }
        }
    }
    public class Html{
        public static void Main(){
            //[1] 객체 생성
            Input input = new Input();
            //[2] 속성 지정
            input.Type = "button";
            input.Value = "짝수의 합";
            //[3] 이벤트 등록
            input.Click += 
                new EventHandler(
                    JavaScript.Calculate);
            //[4] 이벤트 발생
            input.OnClick();//출력
        }
    }
}