Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
TreeNodeCollection 与 System.Windows.Forms 中的一些其他控件集合一样,实现了 IEnumerable。这背后有什么设计原因,还是只是仿制药出现前的遗留问题?
是的,有很多 .NET Framework 集合,它们没有实现通用的 IEnumerable。
我认为那是因为在 2.0 之后没有(至少不那么匹配)FW 的核心部分的开发。
同时我建议您使用以下解决方法:
using System.Linq; ... var nodes = GetTreeNodeCollection().OfType<TreeNode>();
是的,Windows 窗体可以追溯到 .Net 中的泛型之前