当前位置:网站首页>Unity C # basic review 26 - first acquaintance Commission (p447)
Unity C # basic review 26 - first acquaintance Commission (p447)
2022-06-29 15:12:00 【_ A little QQ】
entrust Delegate
C# Medium Delegate Corresponding to C The pointer in , But it's different C A pointer in can point to a method , It can also point to variables , And you can do type conversion ,
C The pointer in is actually a memory address variable , It can operate memory directly , Through memory
Address direct access to variables , Direct call method .
and C# Medium Delegate It's a strong type of , That is, when the delegate is declared, it has been specified
This variable can only point to a specific parameter , And the method of returning the value .
Use delegate You can directly create a delegation type with any name , When the system is compiled
when , The system will automatically generate this type . You can use delegate void MyDelegate()
Method to create a delegation class , And use ILDASM.exe Observe its members . from ILDASM.exe
Can be seen in , It inherited System.MulticastDelegate class , And automatically generate BeginInvoke、EndInvoke、Invoke Three common methods .
Invoke Method is the corresponding method used to synchronously call the delegate object , and BeginInvoke、EndInvoke Is used to call the corresponding method asynchronously .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Skill
{
public void Skill1()
{
Console.WriteLine("Skill: Skill 1 Animation ");
}
public void Skill2()
{
Console.WriteLine("Skill: Skill 2 Animation ");
}
public void Skill3()
{
Console.WriteLine("Skill: Skill 3 Animation ");
}
public void Skill4()
{
Console.WriteLine("Skill: Skill 4 Animation ");
}
public void Skill5()
{
Console.WriteLine("Skill: Skill 5 Animation ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
delegate void AutoSkillPlayer();
class Program
{
static void Main(string[] args)
{
AutoSkillPlayer akp = new AutoSkillPlayer(Skill1);
akp += Skill3;
akp += Skill4;
Skill sk = new Skill();
akp += sk.Skill4;
akp -= Skill1;
akp.Invoke();
}
public static void Skill1()
{
Console.WriteLine(" Skill 1 Animation ");
}
public static void Skill2()
{
Console.WriteLine(" Skill 2 Animation ");
}
public static void Skill3()
{
Console.WriteLine(" Skill 3 Animation ");
}
public static void Skill4()
{
Console.WriteLine(" Skill 4 Animation ");
}
public static void Skill5()
{
Console.WriteLine(" Skill 5 Animation ");
}
}
}

边栏推荐
- Unity C# 基础复习27——委托示例(P448)
- const用法精讲
- Solidworks零件图存放位置更改后装配图识别不出来的解决办法
- phpcms打开后台首页时向官网发送升级请求觉得卡怎么办?
- Lumiprobe 点击化学丨非荧光炔烃:己酸STP酯
- 广州期货正规吗?如果有人喊你用自己的手机登,帮忙开户,安全吗?
- Jet hydrogen technology rushes to the scientific innovation board: SAIC Group is the major shareholder to raise 1.06 billion yuan
- 二级指针
- 打造一个 API 快速开发平台,牛逼!
- Lumiprobe deoxyribonucleic acid alkyne DT phosphimide
猜你喜欢

ROS notes (10) - Launch file startup

Secondary pointer

Solidworks零件图存放位置更改后装配图识别不出来的解决办法

Weigao blood purification sprint to Hong Kong: annual revenue of RMB 2.9 billion, net profit decreased by 12.7%

文本预处理库spaCy的基本使用(快速入门)

Lumiprobe deoxyribonucleic acid phosphate CpG 1000 solid carrier

华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍

FIFO implementation with single port RAM

ModStartBlog 现代化个人博客系统 v5.2.0 主题开发增强,新增联系方式

关于项目采购管理,这些你需要知道
随机推荐
Lumiprobe deoxyribonucleic acid phosphate CpG 1000 solid carrier
MCS:多元随机变量——离散随机变量
Lumiprobe 点击化学丨非荧光叠氮化物:叠氮化物-PEG3-OH
Analysis of constant current source circuit composed of two NPN tubes
材质 动态自发光
Informatics Olympiad all in one 1003: aligned output
SOFARegistry 源码|数据同步模块解析
【牛客网刷题系列 之 Verilog快速入门】~ 移位运算与乘法
BioVendor游离轻链(κ和λ)Elisa 试剂盒的化学性质
Lumiprobe reactive dye - amino dye: cyanine 5 amine
go学习(四、面向接口)
Chaîne lumineuse libre biovendor κ Et λ) Propriétés chimiques du kit ELISA
word如何自动生成目录
信息学奥赛一本通1002:输出第二个整数
MCS:离散随机变量——几何分布
For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?
What should phpcms do when it sends an upgrade request to the official website when it opens the background home page?
Wechat official account - menu
Intelligent diagnosis of Alzheimer's disease
捷氢科技冲刺科创板:拟募资10.6亿 上汽集团是大股东