VB.Net

VB.Net Collections

VB.Net Collections

Collection classes are specialized data storage and retrieval classes. Stacks, queues, lists, and hash tables are all supported by these classes. The interfaces of most collection classes are the same.

Collection classes perform various functions, such as dynamically allocating memory to elements and accessing a list of objects by an index. These classes generate objects from the Object class, which serves as the foundation for all data types in VB.Net.

Collection Classes and their usage

The System.Collection namespace most commonly used classes are listed below:

Class

Description and Usage

ArrayList

It represents an ordered collection of objects that may be individually indexed.

It is essentially an array substitute. However, unlike arrays, you can add and remove items from a list at a specific point using an index, and the array automatically resizes itself. It also supports dynamic memory allocation and the addition, search, and sorting of objects in a list.

Hashtable

It makes use of a key to gain access to the objects in the collection.

You utilise a hash table when you need to access elements by key and can determine a reasonable key value. Each hash table item has a key/value pair. The key is used to gain access to the collection's items.

SortedList

To access the items in a list, it employs both a key and an index.

A sorted list combines an array with a hash table. It comprises a list of objects that can be accessed when you pass parameters by reference key or an index. If you access things by index, it's an ArrayList; if you access items by key, it's a Hashtable. The key value is always used to sort the collection of items.

Stack

It represents a group of objects arranged in a last-in, first-out order.

It is utilized when objects must be accessed last-in-first-out. When you add an item to the list, this is referred to as pushing the item, and when you remove it, this is referred to as popping the item.

Queue

It symbolizes a collection of objects arranged in a first-in, first-out order.

It is utilized when objects must be accessed first-in-first-out. When you add an item to the list, it is referred to as enqueue, and when you delete an item, it is referred to as deque.

BitArray

It depicts a binary representation array with the values 1 and 0.

It is used when you need to store bits but don't know how much you'll need ahead of time. Items in the BitArray collection can be accessed by using an integer index that begins with zero.

 

Top course recommendations for you

    Merge Sort Algorithm Using Java
    1 hrs
    Beginner
    1.2K+ Learners
    4.68  (28)
    Python IDE
    3 hrs
    Beginner
    3.4K+ Learners
    Searching Algorithms in Java
    2 hrs
    Beginner
    1.7K+ Learners
    4.65  (66)
    Graphs in Java
    2 hrs
    Intermediate
    2.4K+ Learners
    4.57  (53)
    Java Data Structures for Beginners
    3 hrs
    Beginner
    11K+ Learners
    4.58  (424)
    Java Data Structures for Intermediate Level
    3 hrs
    Intermediate
    6.6K+ Learners
    4.4  (183)
    Graphs in Python
    1 hrs
    Beginner
    2.8K+ Learners
    4.52  (89)
    Data Structures & Algorithms in Java
    4 hrs
    Beginner
    165.7K+ Learners
    4.49  (2891)
    Java Programming
    2 hrs
    Beginner
    627.4K+ Learners
    4.48  (42524)
    Python Fundamentals for Beginners
    8 hrs
    Beginner
    712.8K+ Learners
    4.55  (40030)