我已經強類型類,複印數組元素
Public Class RowData
Sub New(ByVal rRecord As String, ByVal rAccount As String, _
ByVal soExperian As Boolean, ByVal soEquifax As Boolean, ByVal soTransunion As Boolean, _
ByVal snExperian As Boolean, ByVal snEquifax As Boolean, ByVal snTransunion As Boolean)
Me.Record = rRecord
Me.Account = rAccount
Me.oExperian = soExperian
Me.oEquifax = soEquifax
Me.oTransunion = soTransunion
Me.nExperian = snExperian
Me.nEquifax = snEquifax
Me.nTransunion = snTransunion
End Sub
.........
End Class
然後,我使用以下代碼來聲明2層的元件陣列。
Dim Tradelines(1) As List(Of RowData)
Tradelines(0) = New List (Of RowData)
Tradelines(0).Add(New RowData("222", "222", False, False, False, False, False, False))
Tradelines(0)被填充,沒有問題,但是當我使用以下代碼來元-0複製到元-1他們似乎一定要如此,如果我在任一元素更改任何值,則其他元素自動更新。我不想那麼說,任何線索?
Tradelines(1) = Tradelines(0)
他們沒有約束。它們是相同的元素。 – Jonathan 2011-12-26 12:11:04
這個SO帖子涵蓋了它: http://stackoverflow.com/questions/222598/how-do-i-clone-a-generic-list-in-c – Xcalibur37 2011-12-26 15:14:38