C#中Action委托的使用 [英] Uses of Action delegate in C#

查看:29
本文介绍了C#中Action委托的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 中与 Action Delegates 一起工作,希望能更多地了解它们并思考它们可能有用的地方.

I was working with the Action Delegates in C# in the hope of learning more about them and thinking where they might be useful.

是否有人使用过 Action Delegate,如果有,为什么?或者你能举出一些可能有用的例子吗?

Has anybody used the Action Delegate, and if so why? or could you give some examples where it might be useful?

推荐答案

MSDN 说:

这个委托被Array.ForEach 方法和List.ForEach 方法来执行对数组的每个元素进行操作或清单.

This delegate is used by the Array.ForEach method and the List.ForEach method to perform an action on each element of the array or list.

除此之外,您还可以将其用作接受 1-3 个参数而不返回任何值的通用委托.

Except that, you can use it as a generic delegate that takes 1-3 parameters without returning any value.

这篇关于C#中Action委托的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆