![]() |
c# advice for csv files..
Hi, im writing a csv parser and was wondering what you think the best way of returnin the data is. its going to be a class that people can add to there projects. i was going to use arrays but then i remembered that you have to have set the size of the array before the app is compile so thats a problem.. How can i do you do you think ? The csv could have any amount of columns and any amount of lines...
|
If the fixed size is the problem use : List<T> - it's the generic version of ArrayList. So that's that for the number of lines.
|
Does it work like this ?
List<int> blah = new List<int>(); blah.Add(1); |
yeap.
|
hmm, i take it i cant use it like this:
int totalcolumns = 5; int count = 0; while (count < totalcolumns) { List<int> count = new List<int>(); count++; } to have a list for each column... |
could i have a list of arrays ?
|
you sure can. You can have a list of lists like :
List<List<string>> xxx = new List<List<string>>(); so xxx[0] will return a List<string>.(that would be one row from the file.) |
Personally I'd do it with ArrayList (when I say I'd do it with ArrayList, I mean that's what I did it with, I have both CSV pasers and CSV writers)
|
I agree that a strong-typed list is not neccesary unless explicitly called for, an ArrayList also has a dynamic length.
You could however, as you are talking of above, use generics to keep track of the column and value, but I guess you already have a structure for matching up memorised values already. |
| All times are GMT -5. The time now is 2:47 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC