惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
爱范儿
爱范儿
D
Docker
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
D
DataBreaches.Net
月光博客
月光博客
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Visual Studio Blog
MyScale Blog
MyScale Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
L
LangChain Blog
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学

博客园 - Xia.CJ

node.js中连接mongodb(Please ensure that you set the default write...)解决办法 node.js api解读之file system模块 Node.js小技巧 在windows上安装新版node.js-node.js学习笔记 Asp.Net MVC部暑托管服务器iis7提示403错误解决方法 mvc3中使用unobtrusive时,ajax更新加载页面后验证失效解决方法 ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上 搜索引擎(google/百度)高级指令 在mvc3中使用uploadify上传组件User.isAuthenticated等于false解决方法 MVC中用Html.RenderPartial还是Html.RenderAction或者Html.Partial-Xia.CJ 在_Layout使用Html.RenderAction的问题-MVC3(Razor)问题 无法删除此对象,因为未在 ObjectStateManager 中找到它-entity framework删除时 Javascript数组(array)操作 序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用 entity framework(EF)_code first复杂类型(Complex Types)问题 entity framework多对多关系查询 JQuery获取checkbox值,checkbox全选,操作checkbox JQuery操作Select JQuery动态创建DOM、表单
C# 委托
Xia.CJ · 2026-03-15 · via 博客园 - Xia.CJ

Action 和 Func

action没有返回值。

func有返回值。

Action<T> 

// Action<T> 是系统预定义的委托类型
public delegate void Action<in T>(T obj);  // 简化表示

// 所以 Action<object> 相当于:
public delegate void MyAction(object obj);  // 接收object参数,无返回值

2. 不同形式的Action委托

// 无参数
Action action1 = () => Console.WriteLine("无参数");

// 一个参数
Action<string> action2 = (s) => Console.WriteLine(s);  // string参数
Action<object> action3 = (o) => Console.WriteLine(o);  // object参数

// 多个参数
Action<int, string> action4 = (i, s) => Console.WriteLine($"{i}:{s}");
Action<int, int, int> action5 = (a, b, c) => Console.WriteLine(a + b + c);