FUNC委托没有返回类型 [英] Func delegate with no return type
问题描述
所有Func键代表返回值。什么是可与返回void
All of the Func delegates return a value. What are the .NET delegates that can be used with methods that return void?
推荐答案
所有Func键代表返回的东西?; 。所有的动作代表返回void
All Func delegates return something; all the Action delegates return void.
Func键< TResult>
不带任何参数,并返回TResult:
Func<TResult>
takes no arguments and returns TResult:
public delegate TResult Func<TResult>()
动作< T>
接收一个参数并没有返回值:
Action<T>
takes one argument and does not return a value:
public delegate void Action<T>(T obj)
动作
是最简单的,'裸'代表:
Action
is the simplest, 'bare' delegate:
public delegate void Action()
还有 Func键< TArg1,TResult>
和动作< TArg1,TArg2>
(和其他人最多四个参数)。所有这些(除了动作< T>
)是新的.NET 3.5(在System.Core程序定义)
There's also Func<TArg1, TResult>
and Action<TArg1, TArg2>
(and others up to four arguments). All of these (except for Action<T>
) are new to .NET 3.5 (defined in System.Core).
这篇关于FUNC委托没有返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!