当前位置:网站首页>A simple example of delegate usage
A simple example of delegate usage
2022-07-07 10:48:00 【HCC2017】
public delegate void LogDelegate(string log); // Definition The delegate name is LogDelegate, With a string Parametric Delegate type
public static LogDelegate LogEvent; // Declare the delegate object , The delegate instance is LogEvent
public static void OnLogEvent(string log)
{
if (LogEvent != null)
{
LogEvent(log);
}
}
}
/// <summary>
/// Add call event , The delegate
/// </summary>
class TextDelegate : MonoBehaviour
{
void Start()
{
TextDelegate2.LogEvent += Cat;
TextDelegate2.LogEvent += Dog;
TextDelegate2.OnLogEvent(" Feed the small animals ");// Send callback information to the function
}
void Cat(string log)
{
Debug.Log(" cat :" + log);
}
void Dog(string log)
{
Debug.Log(" Wang Wang Wang :" + log);
}
}
边栏推荐
- Some online academic report websites and machine learning videos
- ArrayList线程不安全和解决方案
- 软考中级,软件设计师考试那些内容,考试大纲什么的?
- Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记
- 软考一般什么时候出成绩呢?在线蹬?
- 中级网络工程师是什么?主要是考什么,有什么用?
- 一些线上学术报告网站与机器学习视频
- CAS机制
- What is an intermediate network engineer? What is the main test and what is the use?
- 成为优秀的TS体操高手 之 TS 类型体操前置知识储备
猜你喜欢

openinstall与虎扑达成合作,挖掘体育文化产业数据价值
![[daiy5] jz77 print binary tree in zigzag order](/img/ba/b2dfbf121798757c7b9fba4811221b.png)
[daiy5] jz77 print binary tree in zigzag order

多线程-异步编排

Socket通信原理和实践

路由器开发知识汇总

IO model review
![[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer](/img/de/0cf12132216ffbde896a7b12022184.png)
[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer

ArrayList线程不安全和解决方案

使用U2-Net深层网络实现——证件照生成程序

Openinstall and Hupu have reached a cooperation to mine the data value of sports culture industry
随机推荐
2022.7.3DAY595
SQL Server 知识汇集11 : 约束
小程序跳转H5,配置业务域名经验教程
[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer
[recommendation system 02] deepfm, youtubednn, DSSM, MMOE
Applet jump to H5, configure business domain name experience tutorial
Summary of router development knowledge
leetcode-560:和为 K 的子数组
Installation and configuration of slurm resource management and job scheduling system
BigDecimal value comparison
多线程-异步编排
P1031 [NOIP2002 提高组] 均分纸牌
How to successfully pass the senior system architecture designer in the second half of the year?
【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer
Schnuka: machine vision positioning technology machine vision positioning principle
Kotlin realizes wechat interface switching (fragment exercise)
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
Records on the use of easyflash v3.3
555电路详解
枪出惊龙,众“锁”周之