When would you not use Generic Collections?

前端 未结 8 1808
醉酒成梦
醉酒成梦 2021-01-19 00:57

The advantage of using generics is that it increases the type safety - you can only put in the correct type of thing, and you get out the correct type without requiring a ca

相关标签:
8条回答
  • 2021-01-19 01:43

    The obvious other reason is working with code (possibly legacy) that does not use generic collections.

    You can see this happening in .NET itself. System.Windows.Form.Control.Controls is not generic, nor is System.Web.UI.Control.Controls.

    0 讨论(0)
  • 2021-01-19 01:43

    The non-generic Collection in the Microsoft.VisualBasic namespace has some annoying quirks and goofiness, and is in a lot of ways pretty horrible, but it also has a unique feature: it is the only collection which exhibits sensible semantics if it's modified during an enumeration; code which does something like delete all members of a Collection which meet a certain predicate may need to be significantly rewritten if some other collection type is used.

    0 讨论(0)
提交回复
热议问题