课程表

VB.Net基本教程

VB.Net高级教程

工具箱
速查手册

VB.Net - 集合

当前位置:免费教程 » 程序设计 » VB.Net

集合类是用于数据存储和检索的专用类。 这些类提供对堆栈,队列,列表和哈希表的支持。 大多数集合类实现相同的接口。


集合类用于各种目的,例如动态地为元素分配内存以及基于索引访问项目列表等。这些类创建Object类的对象集合,Object类是VB中所有数据类型的基类 。


各种集合类和它们的用法

以下是System.Collection命名空间的各种常用类。 单击以下链接以检查其详细信息。


ClassDescription and Useage

ArrayList

It represents ordered collection of an object that can be indexedindividually.

它表示可以单独索引的对象的有序集合。

It is basically an alternative to an array. However, unlike array, you can add and remove items from a list at a specified position using anindex and the array resizes itself automatically. It also allows dynamic memory allocation, add, search and sort items in the list.

它基本上是一个数组的替代。 但是,与数组不同,您可以使用索引在指定位置从列表中添加和删除项目,并且数组会自动调整大小。 它还允许动态内存分配,添加,搜索和排序列表中的项目。

Hashtable

It uses a key to access the elements in the collection.

它使用一个键来访问集合中的元素。

A hash table is used when you need to access elements by using key, and you can identify a useful key value. Each item in the hash table has a key/value pair. The key is used to access the items in the collection.

当您需要通过使用键访问元素时使用散列表,您可以标识有用的键值。 散列表中的每个项都有一个键/值对。 该键用于访问集合中的项目。

SortedList

It uses a key as well as an index to access the items in a list.

它使用一个密钥以及索引来访问列表中的项目。

A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index. If you access items using an index, it is an ArrayList, and if you access items using a key, it is a Hashtable. The collection of items is always sorted by the key value.

排序列表数组组合包含可以使用索引访问列表如果访问使用索引项目一个 ArrayList如果访问项目使用钥匙一个哈希表集合总是关键排序

Stack

It represents a last-in, first out collection of object.

它表示对象的后进先出的集合。

It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item, and when you remove it, it is calledpopping the item.

当您需要项目的最后进入,首先访问时使用。 当您在列表中添加项目时,称为推送项目,当您删除它时,它被称为弹出项目。

Queue

It represents a first-in, first out collection of object.

它表示对象的先进先出集合。

It is used when you need a first-in, first-out access of items. When you add an item in the list, it is called enqueue, and when you remove an item, it is called deque.

当您需要项目的先进先出访问时使用。 当您在列表中添加项目时,它被称为enqueue,当您删除项目时,称为deque。

BitArray

It represents an array of the binary representation using the values 1 and 0.

它表示使用值1和0的二进制表示的数组。

It is used when you need to store the bits but do not know the number of bits in advance. You can access items from the BitArray collection by using an integer index, which starts from zero.

它用于需要存储位但不提前知道位数。 您可以通过使用从零开始的整数索引来访问BitArray集合中的项目。

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号