开发者

How to call invoke when use Func<string, bool>

开发者 https://www.devze.com 2023-01-25 01:41 出处:网络
In the function Test(Func<string,bool> f), how to call f.invoke(开发者_如何学编程)? I received the error

In the function Test(Func<string,bool> f), how to call f.invoke(开发者_如何学编程)? I received the error Delegate 'Func' does not take '0' arguments


bool b = f(someString);

or:

bool b = f.Invoke(someString);


The delegate Func<string, bool> is a delegate that takes a string as an argument and returns bool. To invoke it, you need to supply a string.

e.g., either should work

f("foo");
f.Invoke("foo");
0

精彩评论

暂无评论...
验证码 换一张
取 消