C#声明一个带返回值的委托

1、声明

public delegate string TestDel(string str);

2、使用

TestDel t;

t = (string str) => str;

t += (string str) => str + "1";

t += (string str) => str + "2";

t += (string str) => str + "3";

Console.WriteLine(t ("hhhh"));

3,总结

(这里添加监听使用了表达式Lambda,参考C#语法_匿名方法与Lambda表达式)

这里会打印hhhh3,也就是最后一个监听的返回值。

相关推荐
EIP低代码平台4 小时前
EIP低代码平台系统-字典功能讲解
低代码·c#·工作流
旧物有情5 小时前
游戏开发常用架构 #MVP,MVC
游戏·unity·架构·mvc
吉普赛的歌5 小时前
YARP负载均衡配置了多个相同接口导致的报错
c#·yarp
张人玉7 小时前
C# WinForms——工厂管理系统(C# WinForms)
数据库·sqlite·c#·winform
勇踏前人未索之境7 小时前
Unity打包运行于鸿蒙手机
unity·智能手机·harmonyos
玖玥拾8 小时前
Unity 3D 笔记(十一)UI 框架进阶:栈弹窗交互、BasePanel 基类虚方法、DoTween 界面动画
笔记·3d·unity
夜莺悠吟9 小时前
关于对 C# 中 ImplicitUsings,GlobalUsings 的讨论
c#·.net
郝学胜-神的一滴10 小时前
中级OpenGL教程 023:Assimp模型加载全解——从源码到架构的骈文探秘
c++·unity·游戏引擎·cmake·unreal engine·opengl
-银雾鸢尾-15 小时前
C#中的拓展方法
开发语言·c#
xcLeigh1 天前
Unity基础:GameObject与Component——Unity核心架构思想彻底理解
unity·教程·component·gameobject