위탁을 이용하여 반향을 실현하다

3285 단어 이루어지다
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace         

{

    class Program

    {



        static void Main(string[] args)

        {



        }

        public delegate void ShowTimeDelegate();

        class A

        {

            public void AShowTime() { }



        }

        class B

        {

            public static void BShowTime() { }

            

        }

        //    controller 

        class Controller

        {

            private ShowTimeDelegate d;//

            public void RegisterDelegateForCallback(ShowTimeDelegate method)

            {

                d += method;//              

            }

            public void UnReginterDelegareForCallback(ShowTimeDelegate method)

            {

                d -= method;//        

            }

            public void CallBack()

            {

                if (d != null)

                {

                    d.Invoke();//           

                }

            }

        }

    }

}

좋은 웹페이지 즐겨찾기