I'm creating an new class object with a property that holds a generic List(of Singles). After creating this object, I change this generic list. Since I didn't pass that list as ByRef in the New-Procedure, I would expect to already created object instance NOT to change, but that not the case. Where am I wrong?
I would have expected that all instances of clVessel in the List "AllVessels" to have different Frequencies, however all have it at the value of 400??Code:'Class Public Class clVessel Public Sub New(ByVal ID As Integer, ByVal Frequencies As List(Of Single)) With Me .ID = ID .Frequenzen = Frequenzen End With End Sub Private _ID As Integer Public Property ID() As Integer Get Return _ID End Get Set(ByVal value As Integer) _ID = value End Set End Property End Class 'in the MainForm Public AllVessels As List(Of clVessel) Dim Frequencies As New List(Of Single) Frequencies.Add(300) For j As Integer = 1 To 100 Frequencies(0) = 300 + j AllVessels.Add(New clVessel(1, Frequencies)) Next




Reply With Quote