C# 事件委托 【开门两次 开枪】

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace TDelegate
{
    public class Program
    {
        //定义委托
        public delegate void knock(int mess);
        //定义事件
        public event knock shot;



        public static void Main()
        {
            Program p = new Program();

            //注册方法
            p.shot += p.Gun;

            //调用方法
            p.KnockDoor();

            Console.ReadKey();

        }

        public void KnockDoor() 
        {
            for (int i = 0; i < 3; i ++ )
            {
                if(i == 2)
                {
                    if(shot != null)
                    {
                        shot(i);  
                    }
                    
                }
            }

        }

        //开枪的方法
        public void Gun(int x)
        {
            Console.WriteLine("开门{0}次,兔兔 吐吐 突突,,,,开枪", x);
        }


    }

    



}


C# 事件委托 【开门两次 开枪】



上一篇:Multi-shot Pedestrian Re-identification via Sequential Decision Making


下一篇:【论文笔记】M2Det: A Single-Shot Object Detector Based on Multi-Level Feature Pyramid Network