What is Array
- When we have to access and manipulate a program by storing a lot of data of the same type, then instead of declaring many Variables to store these same types of data, we do Array Declare.
- Array is a type of Reference Type that uses the Heap Area of Memory to store the same type of Data Items and uses Continues Memory Locations to store every Data Item of Array.
- All data items are stored in memory in a fixed order and a unique Zero Based Unique Index Number is specified with each element to uniquely identify it. Also, Array is a Fixed Data Structure. So once Array's size is defined, then Array's size cannot be modified.
- Array, like Simple Variable, is given the value of thelast index of the array in parentheses (parentheses) after the name of the array while Declare using Dim, Private or Public Statement. Which is called subscript, index or size.
Syntax:
Dim <array name> (subscript) As <Data Type>
Example:
Dim employee_ name (20) As String
Dim
salary (20) As Integer
Types of Array
There are two types of Array in
Visual Basic.
1. One Dimensional Array
2. Multi-Dimensional Array
1.One Dimensional Array:
- Arrays that contain only one index or subscript are called one dimensional arrays. Multiple values can be stored in it. In this, its index is used to store or access a value in an array.
Example: Dim marks (10) As Integer
- The marks array can store 0 to 9 indexes or 10 values in the marks array.Initializing one dimensional Array: values can be inserted in both the design and run time in a dimensional array.
Array index or Curly brackets {} are used to store the
value in design time.
Syntax : Dim Array_name
() As Data type = {element1, element2,….}
Example : Dim name
() As String = {" shaikh ", " vishnu ", " virat "}
or
Dim Name (2) As String
Name (0) = "shaikh "
Name (1) = "vishnu"
Name (2) = "virat"
2.Multi-Dimensional
Array:
- Arrays of many dimensions can be created in VB.Net. Arrays That Contain More Than One Subscripts Are Called Multi-Dimensional Arrays.
- Dim, Private Or Public Statements Are Also Used To Declare Multi-Dimensional Arrays.
- When declare it more than one subscripts are given in it. It can store values equal to multiple of subscripts such that n (2,3) array can store 6 values.
Syntax:
Dim <array name> (script1,
script2…) As <Data Type>
Example:
Dim matrix (3, 3) as Integer
Dim T (2,
3, 4, 2) As Double
Initializing Multi-Dimensional Array: Use Curly brackets to initialize Multi-Dimensional Array.
Dim n (3,
3) As Integer = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
nice post
ReplyDeleteAR Graphics
very good content keep publishing this kind of help full content for us.
ReplyDeletehere is my wesite link you can get quality content about relationship, fitness, health, etc
Illusion lyfstyle
Nice article GET BACKLINK FROM HERE
ReplyDeletenice bro keep it up
ReplyDeleteRanked your website by using this Templates 100% SEO optimized and SEO friendly
exactknow-how
ReplyDeleteexactknow-how
Post a Comment
Please do not any spam link in the comment