I have a 2-dimensional array of string I need to add items to this array based on certain conditions.
Dim mainColumnsSummary(,) As String
mainColumnsSummary = { _
{"slNo", "#", "Number", "30", True, ""}, _
{"assessmentDate", "Assessment Date", "DateTime", "100", True, ""}, _
{"assetDescription", "Description and function of asset", "String", "100", True, ""}, _
{"assetScope", "Scope of assessment", "String", "100", True, ""}, _
{"assetHazards", "Hazard identification", "String", "100", True, ""} _
} if dtTable.rows.count>0 then
' I need to add dtTable.rows(x)("Question") to this array. where x should take values from 0 to dtTable.row.count-1
How can i get this result.
Please help me with code in vb.net.
A .NET array is a data structure with a fixed length. Once created, the .Length property tells you how much elements there are in the array, and the length is constant. You cannot add to an array.
You need to look at System.Collections.Generic.List(Of T).
My VB is not very good, but try something like this:
You should then be able to add as many “rows” to this list as you want.