c# - understand the following lambda -


i have method like

void test(func<bool> f) {     f.invoke(); } 

i pass in test( ()=>getitem("123") )

f.invoke() called getitem("123").

i want know how f know getitem has parameter?

what passing test parameter-less delegate calls getitem method. test method not know parameters getitem. knows delegate calling.

test( ()=>getitem("123") ) 

is equal to

test(delegate { return getitem("abc") ; } ); 

which calling

test(mymethod)    ... bool mymethod() {     return getitem("123"); } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -