Csharp 高级编程 C7.1.2

时间:2014-05-09 10:03:41   收藏:0   阅读:449

第七章 代理(1)

一、代理要声明

二、代理使用步骤

代码示例:

bubuko.com,布布扣
/*C7.1.2*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C7._1._2
{
    class Program
    {
        //声明代理
        private delegate string getStr();

        static void Main(string[] args)
        {
            int x = 10;
            getStr testDeleMethod = new getStr(x.ToString );  //初始化的参数是   实例的一个方法名
            Console.WriteLine("Delegate Method Test: the string type of x is " + testDeleMethod());
            Console.ReadLine();
        }
    }

}
bubuko.com,布布扣

 

Csharp 高级编程 C7.1.2,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!