|
-
Jun 3rd, 2004, 07:14 PM
#1
Thread Starter
Fanatic Member
understanding arrays
I'm trying to get a concept of how an array is used in vb.net.
I read alot, and understand its a list of the same datatype, but I have in my mind its like a grid or something, i think i'm totally off, but what examples could I read to explain how an array is used in coding? Any good tutorials i might have missed?
Sorry for the ignorance
Thanks again guys!
-
Jun 3rd, 2004, 08:25 PM
#2
Fanatic Member
You're not wrong in thinking of an array as a grid - esp. when thinking of multidimensional arrays.
At its simplest though, an array is just a list of objects - be it the built in types (string, int, etc), or your own objects. The grid in this case is just one "column" wide and as many rows as you like.
So we could have an array of members of drpcken's family and then operate on them (via the array) as a group.
Last edited by Briantcva; Jun 4th, 2004 at 09:20 AM.
-
Jun 3rd, 2004, 09:47 PM
#3
Member
Arrays can also eliminate unnecessary coding.
without arrays
Code:
Private Sub InitalizeVars()
dim var1 as integer = 0
dim var2 as integer = 0
dim var3 as integer =0
dim var4 as integer =0
.
.
.
dim var500 as integer =0
end Sub
with arrays
Code:
Private Sub InitalizeVars()
Dim var(499) As Integer
Dim i As Integer = 0
For i = 0 To 499
var(i) = 0
Next
End Sub
Compare 500 lines of code to 5. This is a very simplistic example, but that's how you start out learning.
Jim
-
Jun 3rd, 2004, 10:24 PM
#4
Thread Starter
Fanatic Member
thats awsome
one more then i think i'll get this: so an array is a temp storage space too? hmm, so that would technically make it a variable, but a group of variables as well.
-
Jun 3rd, 2004, 11:10 PM
#5
Lively Member
An array is like a variable, except the memory is still reserved for the number of elements in the array.
Ie. An Integer array with 20 elements the equivalent of declaring 20 integer variables (in terms of memory).
-
Jun 4th, 2004, 02:45 AM
#6
You could think of a 3 dimensional array like this...
Where the 3 dimensions are length, width and height of the cuboid.
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|