I must have been looking at this thing too long. I am trying to populate a list with some custom classes, the issue is that when I clear the temporary list and populate with the next set of data which is then added to the master list it seems to update the previously added class.
Anyone able to shed some light? Just for the record I am only a beginner so the code/method may not be that flash.
thanks in advance
-----------------------------------
Public Class tableData
Public identifier As Integer
Public xyList As List(Of XYdata)
Public Sub New(ByVal m_identifier As Integer, ByVal m_xyList As List(Of XYdata))
identifier = m_identifier
xyList = m_xyList
End Sub
End Class
Public Class XYdata
Public xVal As Integer
Public yVal As Integer
Public Sub New(ByVal m_xVal As Integer, ByVal m_yVal As Integer)
xVal = m_xVal
yVal = m_yVal
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim figI4 As New List(Of tableData)
Dim tmpXY As New List(Of XYdata)
tmpXY.Add(New XYdata(20, 100))
tmpXY.Add(New XYdata(30, 150))
tmpXY.Add(New XYdata(40, 200))
tmpXY.Add(New XYdata(50, 250))
'add to main list
figI4.Add(New tableData(90, tmpXY))
'tmpXY.Clear()
tmpXY.Add(New XYdata(2, 100))
tmpXY.Add(New XYdata(3, 150))
tmpXY.Add(New XYdata(4, 200))
tmpXY.Add(New XYdata(5, 250))
'add to main list
figI4.Add(New tableData(100, tmpXY))
For Each item In figI4
MsgBox("Ident: " & item.identifier)
For Each sItem In item.xyList
MsgBox(sItem.xVal)
Next
Next
End Sub
End Class