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

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

问题描述

我是用行动代表工作在C#中更多地了解他们的思路和希望,他们可能是有用的。

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

有没有人使用这个动作代表,如果是,为什么?或者你可以举一些例子,这可能是有用的?

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.

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

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