John Dalberg wrote:
I have seen examples for List<T>.FindAll (findthis)where findthis is a
predicate. How do I pass a parameter to this predicate so that I have
different values to search for? I don't want to use global variables.
You can't use global variables. C# doesn't have global variables.
There have been a number of threads in this newsgroup regarding this and
similar questions. However, the short answer:
Using an anonymous method, you can simply include the necessary
variables in the code explicitly. IMHO this is the best mechanism
(lamba expressions notwithstanding :) ).
Otherwise, you need to put the data into the class instance in which the
delegate method you're using is defined, or at least into a class that's
accessible by that method. A common technique is to define a small
class containing just the data and the delegate method, instantiate the
class and use that instance's method as the delegate.
If the above doesn't answer your question, I recommend a Google Groups
search using the keywords "delegate" and "predicate" , and possibly other
keywords like "parameter" and "variable".
Pete