为什么不是ArrayList中标记为[过时]? [英] Why isn't ArrayList marked [Obsolete]?

查看:275
本文介绍了为什么不是ArrayList中标记为[过时]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个深深的思考和寻找到的<一个实施href="http://msdn.microsoft.com/en-us/library/system.collections.arraylist%28v=VS.100%29.aspx"><$c$c>ArrayList,个人而言,我真的想说的这是过时的,我没有理由后2.0 使用这个类。但因为它是没有标记为 [作废] ,有什么用途,我不知道,比使用一个通用类比较好?如果是,请举个例子。谢谢你。

After a deep thought and looking into the implementation of ArrayList, personally I really want to say It's obsolete, I have no reason to use this class after 2.0. But since it's not marked as [Obsolete], is there any usage that I didn't know, better than using a generic class? If yes, please give an example. Thanks.

修改让我们名单,其中,T&GT; 作为一个例子,它提供了 ArrayList的所有功能,它的强类型。所以,当我们需要使用的ArrayList ?也许有时候它具有更好的性能?我不知道。我AP preciate,如果你能告诉我一些特别的的ArrayList

EDIT Let's take List<T> as an example, it provides all functions of ArrayList, and it's strongly-typed. So when do we need to use ArrayList? Maybe sometimes it has a better performance? I don't know. I appreciate if you can show me something special of ArrayList.

推荐答案

我认为它应该被视为有效过时了新的code,但没有令人信服的理由来标记它已经过时,并创建在所有code警告上面写着2.0发布之前。

I think it should be considered effectively obsolete for new code, but there's no compelling reason to mark it obsolete and create warnings in all code which was written before 2.0 was released.

在我的经验,其中大部分已被标记为已过时微软的类型和成员都在某些方面非常危​​险的,并且应该被固定的,如果你仍然在使用他们一个codeBase的。当使用的ArrayList 是痛苦的,(至少在理论上)容易发现类型相关的错误在执行时,而不是编译时间,种类,它的工作不够好......常实在没有令人信服的理由来改变现有的code。这是怎样的变化我想一般认为,当我已经发生在其上工作的code这是用的ArrayList ,而不是积极地寻找每一个使用面积它。

In my experience, most of the types and members which have been marked obsolete by Microsoft are actively dangerous in some respect, and should really be fixed if you still have a codebase using them. While using ArrayList is painful and (at least theoretically) prone to discovering type-related bugs at execution time rather than compile time, the type does its job well enough... often there's really no compelling reason to change existing code. It's the kind of change I'd generally consider when I already happened to be working on an area of code which was using ArrayList, rather than actively seeking out every usage of it.

这篇关于为什么不是ArrayList中标记为[过时]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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