title: Calling Func inside Func body
body: <p>I'm having some troubles, with a <code>Func</code> that I've written, the IDE doesn't like that I'm calling the <code>Func</code> inside the Func body, and I don't quite understand why because if I put this exact code in a method body instead, with the same return type and argument parameters, then it works.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Func&lt;XElement, TreeNode[]&gt; arrayDel = new Func&lt;XElement,TreeNode[]&gt;(a =&gt; 
          {
              List&lt;TreeNode&gt; nodes = new List&lt;TreeNode&gt;();
              foreach (XElement item in a.Elements())
              {
                  if (item.HasElements) 
                  {
                      nodes.Add(new TreeNode(item.Name.ToString(), arrayDel(item))); }
                  else 
                  { 
                      nodes.Add(new TreeNode(item.Name.ToString())); }
              }
              return nodes.ToArray();
  </code></pre>