|
-
Nov 13th, 2008, 04:35 PM
#1
Thread Starter
Addicted Member
Add rows to 2D arrays
I have a 1 dimensional array, and I need to add it as a new line to a 2D array, how do I do this?
I actually have many 1D arrays, but I need to make them 1 2D array. Then later pull them back out into 1D arrays.
How do I do this?
-
Nov 13th, 2008, 04:39 PM
#2
Re: Add rows to 2D arrays
Are they all (the 1D arrays) have the same demensions?
Must you use a 2D array? If you don't have to use a 2d array, you can use a List to hold the 1D arrays.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Nov 13th, 2008, 04:45 PM
#3
Thread Starter
Addicted Member
Re: Add rows to 2D arrays
 Originally Posted by stanav
Are they all (the 1D arrays) have the same demensions?
Must you use a 2D array? If you don't have to use a 2d array, you can use a List to hold the 1D arrays.
Well I'm importing lines of comma separated text from a file then parsing it to a 1D array. Each post parsed line arrays will be of the same length, yes. Each array line carries information pertaining to file, however I'll have many lines in to import (one for each file recorded), so I cant pre-define each 1D array, for it could be on the order of hundreds of 1D arrays, and the total number arrays will constantly be changing as the number of line entries in the imported document change.
How would I go about using a list?
-
Nov 13th, 2008, 04:57 PM
#4
Re: Add rows to 2D arrays
Forget the array approach. Use a datatable. You can use ADO.Net to import a csv file to a datatable fairly easy. You can search this forum for code example of importing csv file to a datatable (search for something like "csv to datatable").
On the other hand, if you want to use a list you can do this:
Code:
'Declare a list of string array
Dim myList As New List(Of String())
'Then when you read your csv file, after each line is converted to a
'string array, you add it to the list
'your code to open the file here... I don't want to rewrite it
line = reader.ReadLine()
'Split the line at the comma's into an array, then add it to the list
myList.Add(line.Split(","c))
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
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
|