Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of Array() in VB.NET?

Tags:

vb.net

vb6

In VB6 you can do this:

Dim a As Variant
a = Array(1, 2, 3)

Can you do a similar thing in VB.NET with specific types, like so?:

Dim a() As Integer
a = Array(1, 2, 3)
like image 218
guillermooo Avatar asked Oct 27 '08 23:10

guillermooo


People also ask

How do you write an array in Visual Basic?

Visual Basic Arrays Declaration In visual basic, Arrays can be declared by specifying the type of elements followed by the brackets () like as shown below. Dim array_name As [Data_Type](); Here, array_name represents the name of an array and Data_type will represent the data type of elements to store in an array.

What is static array in VB?

Static and dynamic arraysStatic arrays must include a fixed number of items, and this number must be known at compile time so that the compiler can set aside the necessary amount of memory. You create a static array using a Dim statement with a constant argument: ' This is a static array.

What is dynamic array in VB?

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 for ReDim statement − ReDim [Preserve] arrayname(subscripts)

What is static and dynamic array in VB?

In VB6 you have two different kinds of arrays, static and dynamic. A VB6 static array is defined by means of a DIM keyword that specifies lower and upper indexes, whereas a dynamic array is defined by means of a DIM keyword with empty parenthesis. Dim arr1(10) As Integer ' a static array.


1 Answers

Dim a() As Integer = New Integer() {1, 2, 3}
like image 95
Jonathan Allen Avatar answered Sep 18 '22 14:09

Jonathan Allen