David Smith

David Smith

  • NA
  • 2k
  • 0

LINQ HELP

Jul 25 2012 5:27 PM
I need some LINQ help.

I have an object (TreeNodeCollection) that contains an object (Nodes), also of type TreeNodeCollection.  I wish to know how many of those sub-nodes have a count of not equal to zero.  Below is the code I am using.  There should be a better way to get the count other than selecting all the items and using the Count function.  Can you help?


         var a = from TreeNode x in nodes where x.Nodes.Count != 0 select x;
         int numTasks = a.Count();

Answers (2)