How can I use a Lambda expression as parameter in this method and use it in the where clause?
Been reading about Func, dynamic and Expression trees but not sure how to do this.
Problem is that I don’t know the type T and don’t know what the caller want returned.
How can I do this in C# 4.0?
An example to get me started would be great – thanks.
Here is a strongly simplified example of what I want.
static public List<T> Match(string startfilelocation, ???)
{
var filelist = Directory.GetFiles(startfilelocation, "*.*", SearchOption.AllDirectories);
return filelist.Where(???);
}
Thank you.
Specify
List<string>as the return type, use theFunc<string, bool>type for the parameter, then theToListmethod to turn the result into a list:Example: