This may sound like a bit of a dumb question but how do I make a Func<>
variable that doesn't return anything?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use Action<T>
for a delegate that takes a variable and returns void
.
But note that you can also just declare your own delegate types if you want to. Action<T>
, for example, is just
public delegate void Action<T>(T obj)
回答2:
Will the Action<T> delegate work for you?
Action<T>
回答3:
You may want:
Action<T> a = (t) => // your code here...