【发布时间】:2010-08-31 15:52:59
【问题描述】:
当 RowCollection 为 50000+ 时,以下函数会出现内存不足的异常,因此我需要提高内存效率。该函数只需要构造一个逗号分隔的字符串,存储在 RowCollection 中的行索引。任何人都可以在下面发现任何明显的内存消耗操作吗?
N.B RowCollection 仅包含存储为整数的行索引列表。
Private Function GetCommaSeparatedString(ByRef RowIndexes As ArrayList) As String
Dim RowString As String = String.Empty
'Build a string of the row indexes
'Add one onto each index value so our indexes begin at 1
For Each Row In RowIndexes
RowString += CInt(Row.ToString) + 1 & ","
Next
'Remove the last comma
If RowString.Length > 0 Then
RowString = RowString.Substring(0, RowString.Length - 1)
End If
Return RowString
End Function
提前致谢。
【问题讨论】:
-
正确的拼写是“分隔”。
-
顺便说一句,为什么要
ArrayList?这看起来像是List<int>的工作。
标签: .net performance arraylist memory-management string-concatenation