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();

    }

  }

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-05-07
  • 2021-12-14
  • 2021-06-02
  • 2021-11-03
  • 2021-09-03
猜你喜欢
  • 2022-01-30
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-02-27
相关资源
相似解决方案