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
    917 Learners
    4.56  (18)
    Python IDE
    3 hrs
    Beginner
    1.7K+ Learners
    Searching Algorithms in Java
    2 hrs
    Beginner
    1.4K+ Learners
    4.69  (29)
    Graphs in Java
    2 hrs
    Intermediate
    1.9K+ Learners
    4.53  (32)
    Java Data Structures for Beginners
    3 hrs
    Beginner
    9.3K+ Learners
    4.54  (231)
    Java Data Structures for Intermediate Level
    3 hrs
    Intermediate
    5.5K+ Learners
    4.46  (122)
    Graphs in Python
    1 hrs
    Beginner
    2.3K+ Learners
    4.43  (56)
    Data Structures & Algorithms in Java
    4 hrs
    Beginner
    155.4K+ Learners
    4.27  (491)
    Java Programming
    2 hrs
    Beginner
    524.2K+ Learners
    4.45  (11)
    Python Fundamentals for Beginners
    4 hrs
    Beginner
    621.2K+ Learners
    4.55  (11)