i have found following part of code in examples while learning func<> syntax:
public static class lambda { public static int myfunc(func<string, int> func) { //some logic return 0; } } and sample call :
var getint = lambda.myfunc((url) => { console.writeline(url); return 0; } and question :
why passing above func lambda expression (url) allowed if value never assigned ( or maybe ?)? point of passing func ?
edit : clarify question . wondering sample call - why passing string argument above (using lambda (url) => {} ) not forbidden compiler if value can not initiated. there example can useful passing string above ?
url name of parameter lambda expression. it's writing method this:
public static int foo(string url) { console.writeline(url); return 0; } then creating delegate it:
func<string, int> func = foo; now in order call delegate, need provide string - , becomes value of parameter, if called method normally:
int result = func("some url");
Comments
Post a Comment