2012-05-12 93 views
2

我有一個二維數組的字符串我需要添加項目到這個數組基於一定的條件。添加動態值到字符串的二維數組

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 

我怎樣才能得到這樣的結果。 請幫我使用vb.net的代碼。

回答

0

.NET數組是具有固定長度的數據結構。 .Length屬性一旦創建,就會告訴你數組中有多少元素,長度是不變的。你不能添加到數組。

您需要查看System.Collections.Generic.List(Of T)。

我的VB是不是很好,但嘗試這樣的事:

Dim mainColumnsSummary As New List(Of String()) 

mainColumnsSummary.Add({"slNo", "#", "Number", "30", True, ""}) 

然後,您應該能夠儘可能多的「行」,只要你想添加到這個列表。