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

Popular posts from this blog

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

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

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