TreeNodeCollection, like some of the other control collections in System.Windows.Forms, implements IEnumerable. Is there any design reason behind this or is it just a hangover from the days before generics?
Yes, there are many .NET Framework collection, that does not implement generic IEnumerable.
I think that's because after 2.0 there was no (at least not so match) development of the core part of FW.
Meanwhile I suggest you to make use of following workaround:
using System.Linq;
...
var nodes = GetTreeNodeCollection().OfType<TreeNode>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With