pass variable to method c# code example
Example: pass function in as variable C#
void Function(Func<int> function) //Func<Type> 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> type cannot be void. The function must return something