Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not entirely sure what you are trying to do, but if you had something like this:</p> <pre><code>public class FWrapper&lt;TChild, TResult&gt;{ private int childCount; private string name; private Func&lt;TChild, TResult&gt; function; public Func&lt;TChild, TResult&gt; Function { get { return function; } } public FWrapper(Func&lt;TChild, TResult&gt; Function, int ChildCount, string Name){ this.childCount = ChildCount; this.name = Name; this.function = Function; } } public class Node&lt;TChild, TResult&gt;{ private FWrapper&lt;TChild, TResult&gt; fw; private IEnumerable&lt;TChild&gt; children; public Node(FWrapper&lt;TChild, TResult&gt; FW, IEnumerable&lt;TChild&gt; Children){ this.fw = FW; this.children = Children; } public IEnumerable&lt;TResult&gt; Evaluate(){ var results = new List&lt;TResult&gt;(); foreach(var c in children){ results.Add(fw.Function(c)); } return results; } } </code></pre> <p>You now have a FWrapper class that takes in any function that takes TChild as a parameter and returns a TResult and a Node class that works with the same TChild and TResult types, so, for example you could do this (trivial example)</p> <pre><code>//Generic function that takes an int and returns a string var func = new Func&lt;int, string&gt;(childInt =&gt; { var str = "'" + childInt.ToString() + "'"; return str; }); var fw = new FWrapper&lt;int, string&gt;(func, 10, "Foobar"); var children = new List&lt;int&gt;(){ 1,2,3,4,5,6,7,8,9,10 }; var node = new Node&lt;int, string&gt;(fw, children); var results = node.Evaluate(); foreach(var r in results){ Console.WriteLine(r); } //'1' //'2' //.. //.. //'9' //'10' </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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