Declaration of an array in microsoft visual basic is achieved by specifying the upperbound of the array ::
dim arr(4) as Integer
Console.WriteLine($“Length of the array = {arr.Length}”)
The length is returned as 5.
In mercury, declaration of an array is achieved by specifying the array length :
dim arr(4) as Integer
Console.WriteLine($“Length of the array = {arr.Length}”)
The length is returned as 4.
Module Program
dim arr(4) as Integer //4 indicates upper bound so (0,1,2,3,4) or 5 elements total vs C-based languages in which 4 indicates 4 elements
Sub Main(args as String())
Console.WriteLine($“Length of the array = {arr.Length}”) // returns 4 in version .2813, returns 5 as of version .2821
End Sub
End Module
Thanks for sorting that.
Having issues with initialising arrays still as in the code below
Dim januaryInquiries(30)() As String
jagged array januaryInquiries is nil after this statement
If a jagged array is initialised at time of declaration, it works as in : Dim values()() As Integer = {
New Integer() {1,2,3},*
New Integer() {1,2},*
New Integer() {1,2,3},*
New Integer() {1,2,3, 4}*
}*
Dim intArray() As Integer = New Integer(4) {} intArray(0) = 25
intArray is not nil, but any attempt to assign a value to the array element results in a IndexOut OfRange exception.