文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>委托动态注入一段代码

委托动态注入一段代码

时间:2011-05-09  来源:易步行天

using System;

using System.Collections.Generic;

using System.Text;

namespace DelegateTest

{

  public class Writer

  {

    public string Text;

    public int Counter;

    public void Dump()

    {

      Console.WriteLine(Text);

      Counter++;

    }

  }

  class Program

  {

    public delegate void Delegate1();

    static void Repeat10Times(Delegate1 somework)

    {

      for(int i=0;i<10;i++)

        somework();

    }

    static void Main(string[] args)

    {

      Writer writer=new Writer();

      writer.Text="Hello";

      Repeat10Times(writer.Dump);

      Console.WriteLine(writer.Counter);

      Console.Read();

    }

  }

}

相关阅读 更多 +
排行榜 更多 +
《上古卷轴5:天际重制版》时髦的兽人宝箱MOD

《上古卷轴5:天际重制版》时髦的兽人宝箱MOD

行业软件 下载
《星露谷物语》丰饶角MOD

《星露谷物语》丰饶角MOD

行业软件 下载
《怪物猎人:荒野》街头霸王6春丽泳装MOD

《怪物猎人:荒野》街头霸王6春丽泳装MOD

行业软件 下载