代码描述人生

.NET 相关技术 (大坏蛋的blog)

博客园 首页 新随笔 联系 订阅 管理
委派返回值为其函数列表中最后一个调用的返回值,不过一般我们不会去关心它。
简单示例如下:
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
namespace ConsoleApplication3
{
    class Program
    {
        delegate string DelegateTest(string input);
        static void Main(string[] args)
        {
            DelegateTest din = new DelegateTest(Test1);
            din += new DelegateTest(Test2);
            string rlt = din("123");
            Console.WriteLine(rlt);
            Console.ReadLine();
        }
        static string Test1(string inp)
        {
            Console.WriteLine("Test1");
            return "test1";
        }
        static string Test2(string inp)
        {
            Console.WriteLine("Test2");
            return "test2";
        }
    }
}
posted on 2004-08-09 22:44  大坏蛋  阅读(902)  评论(0)    收藏  举报