Define arrays withs its types and example.
An array stores a fixed-size sequential collection of elements of the same
type. An array is used to store a collection of data, but it is often more
useful to think of an array as a collection of variables of the same type.
All arrays consist of contiguous memory locations. The lowest address
corresponds to the first element and the highest address to the last element.
Types of array with examples:
a. Dynamic Arrays
Dynamic arrays are arrays that can be dimensioned and re-dimensioned as par
the need of the program. You can declare a dynamic array using the ReDim
statement.
Syntax:
ReDim [Preserve] arrayname(subscripts)
Example:
ReDim Preserve marks(10)
b. Multi-Dimensional Arrays
VB.Net allows multidimensional arrays. Multidimensional arrays are also called
rectangular arrays.
You can declare a 2-dimensional array of strings as:
Dim twoDStringArray(10, 20) As String
Or,
You can a 3-dimensional array of Integer variables:
Dim threeDIntArray(10, 10, 10) As Integer
c. Jagged Array
A Jagged array is an array of arrays. The follwoing code shows declaring a
jagged array named scores of Integers:
Dim scores As Integer()() = New Integer(5)(){}
Labels: VB.Net
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home