Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Hierarchical Query Start with connect by prior 階層式查詢用法 SELECT s.role_id, s.role_name, s.role_base_on, b.role_name role_base_on_name FROM m_usr_role s... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data....
Stats
review : delegate in c#
I think I've got old because while using delegate, I couldn't remember it's usage. So I think it's a good idea to take a review and memo it here.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace wfConsole
{
    delegate void PrintLine();
    delegate void PrintContent(string s, int count);

    public sealed partial class Workflow1 : SequentialWorkflowActivity
    {
        public Workflow1()
        {
            InitializeComponent();
        }

        private void ReviewDelegate_ExecuteCode(object sender, EventArgs e)
        {
            // 委派 C# 1.0
            PrintLine pl = new PrintLine(this.WriteLine);
            PrintContent pc = new PrintContent(this.WriteContent);
            pl.Invoke();
            pc.Invoke("C# 1.0", 5);

            // 委派 C# 2.0
            PrintLine pl2 = delegate()
            {
                Console.WriteLine("********************");
            };
            PrintContent pc2 = delegate(string s, int count)
            {
                for (int i = 0; i < count; i++)
                {
                    Console.Write("{0:00} ", i + 1);
                    Console.WriteLine(s);
                }
            };
            pl2.Invoke();
            pc2.Invoke("C# 2.0", 5);

            // 委派 C# 3.0
            PrintLine pl3 = () =>
            {
                Console.WriteLine("----------------------");
            };
            PrintContent pc3 = (string s, int count) =>
            {
                for (int i = 0; i < count; i++)
                {
                    Console.Write("{0:00} ", i + 1);
                    Console.WriteLine(s);
                }
            };
            pl3.Invoke();
            pc3.Invoke("C# 3.0", 5);

            Console.Read();
        }

        private void WriteLine()
        {
            Console.WriteLine("=========================");
        }

        private void WriteContent(string s, int count)
        {
            for (int i = 0; i < count; i++)
            {
                Console.Write("{0:00} ", i + 1);
                Console.WriteLine(s);
            }
        }
    }

}