当前位置:网站首页>Unity C# 基础复习29——泛型委托(P451)
Unity C# 基础复习29——泛型委托(P451)
2022-06-29 14:39:00 【_一只小QQ】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Soldier
{
int physical;
public Soldier(int physical)
{
this.Physical = physical;
}
public Soldier()
{
}
public int Physical { get => physical; set => physical = value; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Master
{
int physical;
public Master(int physical)
{
this.Physical = physical;
}
public int Physical { get => physical; set => physical = value; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
delegate void AutoTask(Master m);
delegate void AutoTask<T>(T t);
class Program
{
static void Main(string[] args)
{
Master m = new Master(10);
AutoTask<Master> at = Task01;
at += Task02;
at += Task03;
at(m);
Soldier s = new Soldier();
AutoTask<Soldier> at2 = Task01S;
at2 += Task02S;
at2(s);
}
public static void Task01(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务一开启!");
Console.WriteLine("任务一完成!");
}
public static void Task02(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务二开启!");
Console.WriteLine("任务二完成!");
}
public static void Task03(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务三开启!");
Console.WriteLine("任务三完成!");
}
private static void Task02S(Soldier t)
{
Console.WriteLine("任务二开启!");
Console.WriteLine("任务二完成!");
}
private static void Task01S(Soldier t)
{
Console.WriteLine("任务一开启!");
Console.WriteLine("任务一完成!");
}
}
边栏推荐
- EMC-浪涌防护及退耦设计
- Swagger2的配置教程
- 部署搭建decentraland流程讲解
- ModStartBlog 现代化个人博客系统 v5.2.0 主题开发增强,新增联系方式
- Analysis of constant current source circuit composed of two NPN tubes
- 揭秘!付费会员制下的那些小心机!
- Research Report on research and development prospect of China's urea dioxide industry (2022 Edition)
- Chapter 14 of canvas physical animation
- Illustration of Ctrip quarterly report: net revenue of RMB 4.1 billion has been "halved" compared with that before the outbreak
- If I am in Foshan, where can I open an account? Is it safe to open an account online?
猜你喜欢

The 5th China software open source innovation competition | opengauss track live training

知乎热议:一个程序员的水平能差到什么程度?

Imitation headline news information DZ template discuz news information business version GBK template source code

技术沟通遇到3个为什么背后的逻辑

redis在window和Linux环境下的安装

他山之石 | 丁香园 医疗领域图谱的构建与应用

Heavyweight! The latest SCI impact factors were released in 2022, and the ranking of the three famous journals NCS and the top10 of domestic journals has changed (the latest impact factors in 2022 are

EMC-浪涌防护及退耦设计

Campus errands wechat applet errands students with live new source code

Explanation on deployment and establishment of decentraland process
随机推荐
卫龙更新招股书:年营收48亿 创始人刘卫平家族色彩浓厚
建立自己的网站(19)
中国三氧化二砷行业研究与未来预测报告(2022版)
Zhimeng dedecms resource material tutorial download website template source code (with mobile terminal) with installation tutorial
中国二氧化硫脲行业研究与发展前景研究报告(2022版)
Paper study -- accurate accounting of annual total runoff control rate considering the interannual variation characteristics of rainfall
Ogg synchronize MySQL data to greenplus
Configuration tutorial for swagger2
如果我在佛山,到哪里开户比较好?究竟网上开户是否安全么?
Evaluation index of high concurrency software (website, server interface)
delphi7中 url的编码
curl: (56) Recv failure: Connection reset by peer
Deploy redis sentry in k8s
EMC-浪涌防护及退耦设计
模电 2个NPN管组成的恒流源电路分析
Draw a slash on a plane coordinate
第五届中国软件开源创新大赛 | openGauss赛道直播培训
Opengauss community establishes sig knowledgegraph
MySQL中100w数据表比1000w数据表查询更快吗?
【关联分析实战篇】为什么 BI 软件都搞不定关联分析