c# - How to make the following code snippet work and How to pass the parameter to invoke? -
using system;
f.involk() failed since needs string parameter, how correct code?
namespace lamdatest { class program { static void test(func<string,bool> f) { **f.invoke();** } static bool getitem(string s) { console.writeline("getitem"); if (s == "123") return true; else return false; } static void main(string[] args) { test((string s)=> getitem("123")); } } }
try replacing:
**f.invoke();**
with:
f(null);
however, if not using string
argument, should instead use delegate type func<bool>
or action
.
Comments
Post a Comment