Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Thanks! but I have this error: Error 1 'System.Linq.ParallelEnumerable.OfType<TResult>(System.Linq.ParallelQuery)' is a 'method', which is not valid in the given context Commented Feb 9, 2016 at 8:58
  • @SaberJalilzadeh this should actually be System.Linq.Enumerable.OfType<TResult>. Can you check your using statements? Commented Feb 9, 2016 at 9:00
  • @SaberJalilzadeh added a non-linq version to my answer. Commented Feb 9, 2016 at 9:05
  • I have these using statements: using System.Linq; and using System.Xml.Linq; Commented Feb 9, 2016 at 9:09
  • @SaberJalilzadeh This is an interesting problem...I don't know why your compiler does not choose Enumerable.OfType...works fine here. Your TreeNodes are System.Windows.Forms.TreeNode? Commented Feb 9, 2016 at 9:13