从指定的索引中删除一个对象 [英] remove an object from the specified index

查看:55
本文介绍了从指定的索引中删除一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个对象(类似于arraylist)可以在其中存储对象,然后提供删除对象的选项?
例如

is there an object (something like an arraylist ) that allows storing objects in it and then gives the option to remove an object ?
e.g

dim test as sthing
test.add("FF)
test.add("aa")
test.add("aA")
test.remove("aA")


在此先感谢


thanks in advance

推荐答案

很多.看看 System.Collection.Generic [列表(属于T) [
Lots of them. Have a look at System.Collection.Generic[^] namespace and for example: List (Of T)[^]


每个人最终都能忘记ArrayList吗?仅应使用通用(或专用)容器.在v.2.0中引入泛型后,System.Collections的非泛型部分变得过时了;而此版本之前的任何内容都不足以值得或关注.非泛型版本不够安全(由于需要强制类型转换),并且非常不便.

实际上,请始终使用Mika的建议.


为了表达我对一个年轻而好奇的问询者的同情,在回应OP的评论时,我需要对最著名的文章添加最令人鼓舞的参考,这是每个人必读的文章:
Peter Norvig,十年自学编程
http://norvig.com/21-days.html [^ ].


—SA
Can everyone finally forget ArrayList? Only generic (or specialized) containers should be used. The non-generic part of System.Collections is rendered obsolete with introduction of generics in v.2.0; and anything prior to this version is not good enough to be worth or paying attention. Non-generic versions are not safe enough (due to the need of type cast) and simply inconvenient.

Practically, always use the advice by Mika.


Just to show my sympathy to a young and curious Inquirer, in response to OP''s comment, I need want to add most encouraging reference to a famous article, a must-read for everyone:
Peter Norvig, Teach Yourself Programming in Ten Years, http://norvig.com/21-days.html[^].


—SA


这篇关于从指定的索引中删除一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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