收藏的主要优点是什么,收藏中的最佳类是什么 [英] What is the main advantage of collection and which is the best class in collection

查看:61
本文介绍了收藏的主要优点是什么,收藏中的最佳类是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

集合的主要优点是什么,集合中最好的类是什么?

What is the main advantage of collection and which is the best class in collection

推荐答案

您可以在相关文档中找到问题的答案,请参见,例如选择集合类" [
You may find the answers to you questions inside the related documentation, see, for instance "Selecting a Collection Class"[^] or, somethimes, just using common sense: if there were ''the best'' collection class then what''s the need for the other ones?


没有一个集合通用类比其他任何类都要好.原因很简单:如果Microsoft考虑将两个类添加到库A和B中,并且可以发现类B优于类A,那么为什么要包含类A?对于其他没有受到大脑损害的软件开发人员,也会发生同样的情况.所有这些类出于某些目的都是必需的.

同时,我会警告您不要使用任何非泛型集合类,除非是专门的类.通过在.NET Framework v.2.0中引入泛型,这些类已过时.但是,仅应将它们视为已过时才能进行新开发,这就是为什么它们未正式标记为System.ObsoleteAttribute的原因;如果它们在经过良好测试的旧代码中能很好地工作,那么它们没有任何问题.但是,将它们用于新开发根本没有任何意义:谁需要并且没有明显原因的额外类型的大小写?

—SA
None of the collection generic classes is better than any other. The reason is very simple: if Microsoft considered adding two classes to the library, A and B, and it could be found that class B is better then A, why would they include A? The same would happen to any other software developer not experiencing brain damage. All of those classes are needed for some purposes.

At the same time, I would warn against using any non-generic collection classes, except specialized ones. These classes are rendered obsolete by introduction of generics in .NET Framework v.2.0. However, they should be considered obsolete only for new development, that''s why they are not marked formally with System.ObsoleteAttribute; if they work well in a well-tested legacy code, there is nothing wrong with them. However, using them for new development just makes no sense at all: who needs and extra type case without any apparent reason?

—SA


这篇关于收藏的主要优点是什么,收藏中的最佳类是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆