📜  将函数作为变量传递 C# 代码示例

📅  最后修改于: 2022-03-11 14:48:59.960000             🧑  作者: Mango

代码示例1
void Function(Func function) //Func function is the way to define a function
{
  function(); //Fun the function
}
void DoStuff()
{
  Function(function); //Run the function with another function as the input variable
}
int function() //The function to be passed in
{
  Console.WriteLine("Returns 0");
  return 0;
} 
//Func type cannot be void. The function must return something