62690

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
 

    public delegate void  EventHandler(int i);
    interface IMethod     {
        void Add();
    }
    class C : IMethod       {
        public void  Add()
        {
            Console.WriteLine("implements Imethod");
        }

        void aaa()
        { }
    }

    class A       {
        public int ss = 7;
        public IMethod method;
        public event EventHandler FormEntity_SetData;
        public virtual void GetA()        {
            Console.WriteLine("A.GetA();");
            if (FormEntity_SetData != null)
            {
                FormEntity_SetData(ss); //执行事件
            }
            method.Add();
        }
    }
 
    class B : A {

        public B()
        {
            FormEntity_SetData += new EventHandler(SetData);
            method =new  C();
            ss = 5; 
        }
        public void Do()
        {
            GetA();
        }
        public void SetData(int ss)

       {
            Console.WriteLine(ss.ToString());
        }  
    }
 
    class Program : A
    {
        static void Main(string[] args)
        {
            B c = new B();
            c.Do();
            Console.Read();
        }
    }
        
}

posted @ 2011-05-10 16:20 小小部落 阅读(...) 评论(...) 编辑 收藏