gpt4 book ai didi

c# - 接受空 Lambda 表达式的函数的定义原型(prototype)

转载 作者:行者123 更新时间:2023-11-30 19:24:44 28 4
gpt4 key购买 nike

我想使用 lambda 表达式做一些事情,它不使用任何参数,我知道我可以使用 () => foo() 的形式,但我不知道是什么在将 lambda 作为参数传递的函数原型(prototype)处执行

这是代码

class c {
public static void Main() {
Bar(() => Console.WriteLine("Hey"));
}
public static void Bar(what_goes_here foo) {
foo(); //Should print "Hey"
}
}

最佳答案

Action :

Encapsulates a method that has no parameters and does not return a value.

关于c# - 接受空 Lambda 表达式的函数的定义原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33617195/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com