What is dynamic array?

In this topic, you will learn about, What is a dynamic array and How is it Created?

In Visual Basic Dynamic array allows storing a collection of elements of the same type where it can represent a 1-D array or 2-D array.

Dynamic array use redeems, preserve keywords for declaration.

How to create a dynamic array:

Syntax: Dim <array name> () as <data type >.

Eg: dim arr() as integer
Dim num () as single
use of redeem
arr = redeem integer (1 to 5)
how to increase or decrease dynamic array size.

=> use of preserve keyword:
eg:- arr = redeem integer (5)
arr =reddem preserve integer (5)

Dynamic array offers the facility to grow or shrink array size at the time of creation.
Dynamic array use redeems or preserves keyword to allocate new memory or preserve previous elements.

Dynamic array creates a memory for a 1-D array or 2-D array for any Data type.

Comment below if you have queries related to the above article What is a dynamic array and How is it Created?

See also  Different data types available in Visual Basic