jean ala
asked on
Arrays in VB.net 2005
I have 2 questions in vb:
I am trying to declare an array of an indifinte size but i can't find this explained anywhere.
1. Can you declare an array of indefinite size but without initializing it?
Dim myArray() As Integer --> this does not work
Dim myArray() As Integer = {1,2,3} -> this works but this is not an indefinite? the array has ta size of 3
2. What is the "0" inside the following functions?
MsgBox(myArray.GetLowerBou nd(0))
MsgBox(myArray.GetUpperBou nd(0))
Thanks
I am trying to declare an array of an indifinte size but i can't find this explained anywhere.
1. Can you declare an array of indefinite size but without initializing it?
Dim myArray() As Integer --> this does not work
Dim myArray() As Integer = {1,2,3} -> this works but this is not an indefinite? the array has ta size of 3
2. What is the "0" inside the following functions?
MsgBox(myArray.GetLowerBou
MsgBox(myArray.GetUpperBou
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I mean that there is no language where-ever that has an indefinite array (only on a turing machine, but that has indefinite memory), as long as you mean with indefinite infinitely growable or shrinkable.
Languages that do support growing / shrinkable array type (perl, ruby other scripting languages) do not really support the array type, but support the flexible array type.
The equivalent to that in VB.NET (and any .NET language) is to use the ArrayList. But since an arraylist is limited, you will quickly want to move on to the more versatile and very quick generic List interface, which does all you want and more.
Languages that do support growing / shrinkable array type (perl, ruby other scripting languages) do not really support the array type, but support the flexible array type.
The equivalent to that in VB.NET (and any .NET language) is to use the ArrayList. But since an arraylist is limited, you will quickly want to move on to the more versatile and very quick generic List interface, which does all you want and more.
ASKER
Thanks for the replies.
Yes I meant a growable array. An array that you do not specify size at the time of writing the program and at run time the array will grow.
Do you know the answer to the second question?
Yes I meant a growable array. An array that you do not specify size at the time of writing the program and at run time the array will grow.
Do you know the answer to the second question?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
> 2. What is the "0" inside the following functions?
> MsgBox(myArray.GetLowerBou nd(0))
that is the dimension of the array. A classic array can have multiple dimensions. You can ask for each dimension what the upper bound is. It is something I very rarely encounter in normal encoding practices, but anyway, that's what it means ;)
> MsgBox(myArray.GetLowerBou
that is the dimension of the array. A classic array can have multiple dimensions. You can ask for each dimension what the upper bound is. It is something I very rarely encounter in normal encoding practices, but anyway, that's what it means ;)
Sounds like the question was well answered except for the lowerbound(0) specific.
The (0) returns the lower bound for the indexes of the first dimension of the Array...
http://msdn.microsoft.com/en-us/library/system.array.getlowerbound(VS.71).aspx
The (0) returns the lower bound for the indexes of the first dimension of the Array...
http://msdn.microsoft.com/en-us/library/system.array.getlowerbound(VS.71).aspx
how'd you go?
> Sounds like the question was well answered except for the lowerbound(0) specific.
really? Think my last comment covered that. But good to put the pointer to the reference here.
Doin't expect this user to check back... If you don't ping the thread, you have a chance that it will be cleaned up by the clean up volunteers at some point (3 weeks minimum).
really? Think my last comment covered that. But good to put the pointer to the reference here.
Doin't expect this user to check back... If you don't ping the thread, you have a chance that it will be cleaned up by the clean up volunteers at some point (3 weeks minimum).
ASKER