C \ #, delegate 키워드 사용 방식 테스트

 /**
         * Desc: C#, delegate           
         * Env: VS2010 With SP1
         * Auth: Kagula
         * Date: 2013-03-18
         * Note:
         * [1]  (lambda)        ref/out    UI    ,
         *        label1  。
         * Ref: 
         * [1]《Delegate Class》
         * http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(SYSTEM.DELEGATE);k(DELEGATE);k(DevLang-CSHARP)&rd=true
         * */
        public delegate void MyDelegateType(ref String s,int[] arrayInt,Label label);

        public void FuncWithParam(ref String s, int[] arrayInt, Label label)
        {
            for (int i = 0; i < arrayInt.Length; i++)
            {
                s += " " + i;
            }

            label.Content = s;//label is Label.
        }

        public MainWindow()
        {
            InitializeComponent();

            //  delegate    
            MyDelegateType t = new MyDelegateType(FuncWithParam);

            //      
            String sT = "  ref         ";
            int[] aInt = new int[] {1,2,3};//       

            //  delegate,   
            //t(ref sT, aInt,label1);

            //  delegate,   
            Dispatcher.BeginInvoke(t , new object[]{sT,aInt,label1});
        }

좋은 웹페이지 즐겨찾기