不要使用ArrayList! [英] Don't use ArrayList!

查看:224
本文介绍了不要使用ArrayList!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们经常告诉我不要使用ArrayList在VB.NET让我的阵列。
我想听到有关意见,为什么不应该?什么是用于创建和操作数组内容的最佳方法,尺寸等?

People often tell me not to use ArrayList for making my arrays in VB.NET. I would like to hear opinions about that, why shouldn't I? What is the best method for creating and manipulating array contents, dimensions etc?

感谢。

推荐答案

使用泛型列表来代替。 ArrayList是没有类型的,这意味着你可以有字符串,数字列表,+++。相反,你应该使用一个通用的清单如下:

Use generic lists instead. ArrayList is not typed, meaning that you can have a list with strings, numbers, +++. Rather you should use a generic list like this:

Dim list1 As New List(Of String) ' This beeing a list of string

名单类,您还可以扩展动态列表中,但是,它也执行打字,这有助于编写更干净code(你不必强制转换)和code,它是不容易到错误。

The lists-class also allows you to expand the list on the fly, however, it also enforces typing which helps write cleaner code (you don't have to typecast) and code that is less prone to bugs.

ArrayList是gennerally来说只是一个列表(的对象)

ArrayList is gennerally speaking just a List(Of Object).

这篇关于不要使用ArrayList!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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