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

推荐订阅源

博客园 - 叶小钗
MyScale Blog
MyScale Blog
博客园 - 【当耐特】
I
InfoQ
腾讯CDC
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
D
Docker
MongoDB | Blog
MongoDB | Blog
量子位
博客园_首页

博客园 - 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);