Passing a bool condition to method which I can invoke when I need

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2010-03-15T15:57:31Z Indexed on 2010/03/15 15:59 UTC
Read the original article Hit count: 105

Filed under:

Hi,

I need to pass in a predicate which I can invoke whenever I want (just like a delegate). I am trying to do something like this (I thought Predicate delegate would meet my needs):

MyMethod(Predicate,string> pred);

Called like: MyMethod(s => s.Length > 5);

I want to write the condition inline BUT invoke it when I want, just like a delegate. How could I do this>?

Thanks

© Stack Overflow or respective owner

Related posts about c#