Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One thing I see is that in your code where you call the FindAll method you are trying to use the filter variable as a method. Remove the Parens... </p> <p>I do stuff like this all the time. As a matter of fact I have written several generic processes similar to this.</p> <p>The find delegate has to match Predicate so any method that does so will do this. So for example say you wanted to do something crazy like use reflection for your filter you could do something like this.</p> <pre><code>public class SimpleFind&lt;T_Adaptor, T_Item&gt; { public T_Adaptor AdapterItem { get; set; } public SimpleFind(T_Adaptor item) { this.AdapterItem = item; } public bool FindMyStuff&lt;T_Item&gt;(T_Item value) { // Place your crazy reflection logic here... if (value.Property == AdapterItem.Property) return true; else return false; } } </code></pre> <p>Then your list would use it like so directly:</p> <pre><code>List&lt;T_ITem&gt; items = myItems.Find(new SimpleFind&lt;T_Adaptor, T_Item&gt;(adapterValue).Find); </code></pre> <p>or in the case of your method where you have passed in the predicate delegate already defined:</p> <pre><code>List&lt;T_ITem&gt; items = myItems.Find(filter); </code></pre> <p>I have not compiled this and this is just an assumption that the two generics have matching values but I wanted to show the effect of how you can extend this.</p> <p>However based on what I can see in your code your filter should work if you remove the parens on your filter call since it is a delegate in the correct pattern for the Predicate type.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload