Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition prototype for a function accepting an empty Lambda Expression

Tags:

c#

.net

I want to do something using a lambda expression and it doesn't use any parameters, I know I can use the form () => foo() but I can't figure out what to do at the function prototype where the lambda is passed as a parameter

Here's the code

class c {
    public static void Main() {
        Bar(() => Console.WriteLine("Hey"));
    }
    public static void Bar(what_goes_here foo) {
        foo(); //Should print "Hey"
    }
}
like image 232
Achshar Avatar asked Jul 25 '26 21:07

Achshar


1 Answers

Action:

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

like image 126
clcto Avatar answered Jul 27 '26 11:07

clcto