Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 197 characters in body
Source Link
Chris Taylor
  • 53.8k
  • 10
  • 81
  • 92

Since the number of columns and rows change frequently, you could use dynamic lists rather than a fixed 2D array.

List<List<string>> data = new List<List<string>>(); 

Then as you parse the CSV file you can build up the data dynamically in the above structure, adding a new List<string> to data for each new row in the CSV file.

Update: The VB.NET equivalent is something like

data As New List(Of List(Of String)) 

That being said, @Mark Gravell's suggestion is a far better solution than doing this yourself.

Since the number of columns and rows change frequently, you could use dynamic lists rather than a fixed 2D array.

List<List<string>> data = new List<List<string>>(); 

Then as you parse the CSV file you can build up the data dynamically in the above structure, adding a new List<string> to data for each new row in the CSV file.

Since the number of columns and rows change frequently, you could use dynamic lists rather than a fixed 2D array.

List<List<string>> data = new List<List<string>>(); 

Then as you parse the CSV file you can build up the data dynamically in the above structure, adding a new List<string> to data for each new row in the CSV file.

Update: The VB.NET equivalent is something like

data As New List(Of List(Of String)) 

That being said, @Mark Gravell's suggestion is a far better solution than doing this yourself.

Source Link
Chris Taylor
  • 53.8k
  • 10
  • 81
  • 92

Since the number of columns and rows change frequently, you could use dynamic lists rather than a fixed 2D array.

List<List<string>> data = new List<List<string>>(); 

Then as you parse the CSV file you can build up the data dynamically in the above structure, adding a new List<string> to data for each new row in the CSV file.