<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Help with Object containing  2 other objects' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Help with Object containing  2 other objects' posted on the '.NET General' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Mon, 17 Jun 2013 23:51:49 -0700</pubDate>
    <lastBuildDate>Mon, 17 Jun 2013 23:51:49 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Help with Object containing  2 other objects</title>
      <link>http://www.programmersheaven.com/mb/dotnet/412198/412198/help-with-object-containing--2-other-objects/</link>
      <description>I have 3 classes. They are called Boot,Head,and Shell. A boot contains both a Set of Head objects and a set of Shell objects. &lt;br /&gt;
My classes:&lt;br /&gt;
&lt;br /&gt;
Head.vb&lt;br /&gt;
-------------&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Option Explicit On
Public Class Head
    Inherits BusinessEntity.HeadSet
#Region "Private Variables"
    Private _iVesselID As Integer
    Private _iHeadID As Integer
#End Region

#Region "Constructors"
    Public Sub New()

    End Sub
    Public Sub New(ByVal iVesselID As Integer, ByVal iHeadID As Integer)
        _iVesselID = iVesselID
        _iHeadID = iHeadID
    End Sub
#End Region

#Region "Public Properties"
    Public Property iVesselID() As Integer
        Get
            Return _iVesselID
        End Get
        Set(ByVal iValue As Integer)
            _iVesselID = iValue
        End Set
    End Property
    Public Property iHeadID() As Integer
        Get
            Return _iHeadID
        End Get
        Set(ByVal iValue As Integer)
            _iHeadID = iValue
        End Set
    End Property
#End Region

End Class
Public Class HeadSet
    Inherits Collections.ArrayList

    Public Shadows Function Add(ByVal oValue As Head) As Integer
        If Not oValue Is Nothing Then
            MyBase.Add(oValue)
        End If
    End Function

    Default Public Shadows Property Item(ByVal iIndex As Integer) As Head
        Get
            Return CType(MyBase.Item(iIndex), Head)

        End Get
        Set(ByVal Value As Head)
            MyBase.Item(iIndex) = Value
        End Set
    End Property

End Class
&lt;/pre&gt;&lt;br /&gt;
Shell.vb&lt;br /&gt;
------------&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Option Explicit On
Public Class Shell
    Inherits BusinessEntity.ShellSet

#Region "Private Variables"
    Private _iVesselID As Integer
    Private _iShellID As Integer
#End Region

#Region "Constructors"
    Public Sub New()

    End Sub
    Public Sub New(ByVal iVesselID As Integer, ByVal iShellID As Integer)
        _iVesselID = iVesselID
        _iShellID = iShellID
    End Sub
#End Region

#Region "Public Properties"
    Public Property iVesselID() As Integer
        Get
            Return _iVesselID
        End Get
        Set(ByVal iValue As Integer)
            _iVesselID = iValue
        End Set
    End Property
    Public Property iShellID() As Integer
        Get
            Return _iShellID
        End Get
        Set(ByVal iValue As Integer)
            _iShellID = iValue
        End Set
    End Property
#End Region
End Class

Public Class ShellSet
    Inherits Collections.ArrayList

    Public Shadows Function Add(ByVal oValue As Shell) As Integer
        If Not oValue Is Nothing Then
            MyBase.Add(oValue)
        End If
    End Function

    Default Public Shadows Property Item(ByVal iIndex As Integer) As Shell
        Get
            Return CType(MyBase.Item(iIndex), Shell)

        End Get
        Set(ByVal Value As Shell)
            MyBase.Item(iIndex) = Value
        End Set
    End Property

End Class

&lt;/pre&gt;&lt;br /&gt;
And Boot.vb&lt;br /&gt;
-------------&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Option Explicit On
Public Class Boot
    'Contains a head and shell
#Region "Private Variables"
    Private _oHeadSet As New HeadSet
    Private _oShellSet As New ShellSet
    Private _iBootID As Integer
    Private _iVesselID As Integer
#End Region

#Region "Constructors"
    Public Sub New()
        _oHeadSet = New BusinessEntity.HeadSet
        Dim oHead As New Head
        _oHeadSet.Add(oHead)
        _oShellSet = New BusinessEntity.ShellSet
        Dim oShell As New Shell
        _oShellSet.Add(oShell)

    End Sub
    Public Sub New(ByVal oHeadSet As HeadSet, ByVal oShellSet As ShellSet, ByVal iBootID As Integer, ByVal iVesselID As Integer)
        _oHeadSet = New BusinessEntity.HeadSet
        _oShellSet = New BusinessEntity.ShellSet
        Dim oHead As New Head
        Dim oShell As New Shell
        _oHeadSet.Add(oHead)
        _oShellSet.Add(oShell)
        _iBootID = iBootID
        _iVesselID = iVesselID

    End Sub
#End Region

#Region "Public Properties"
    Public Property oHeadSet() As BusinessEntity.HeadSet
        Get
            Return _oHeadSet
        End Get
        Set(ByVal oValue As HeadSet)
            _oHeadSet = oValue
        End Set
    End Property

    Public Property oShellSet() As BusinessEntity.ShellSet
        Get
            Return _oShellSet
        End Get
        Set(ByVal oValue As ShellSet)
            _oShellSet = oValue
        End Set
    End Property

    Public Property iBootID() As Integer
        Get
            Return _iBootID
        End Get
        Set(ByVal iValue As Integer)
            _iBootID = iValue
        End Set
    End Property
  
    Public Property iVesselID() As Integer
        Get
            Return _iVesselID
        End Get
        Set(ByVal iValue As Integer)
            _iVesselID = iValue
        End Set
    End Property
#End Region
End Class


Public Class BootSet
    Inherits Collections.ArrayList

    Public Shadows Function Add(ByVal oValue As Boot) As Integer
        If Not oValue Is Nothing Then
            MyBase.Add(oValue)

        End If
    End Function

    Default Public Shadows Property Item(ByVal iIndex As Integer) As Boot
        Get
            Return CType(MyBase.Item(iIndex), Boot)

        End Get
        Set(ByVal Value As Boot)
            MyBase.Item(iIndex) = Value
        End Set
    End Property

End Class

&lt;/pre&gt;&lt;br /&gt;
And a function from my code behind webpage, to implement&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 Public Function BuildEM() As BusinessEntity.BootSet
        oHead = New BusinessEntity.Head
        oHeadSet = New BusinessEntity.HeadSet
        oShell = New BusinessEntity.Shell
        oShellSet = New BusinessEntity.ShellSet
        oBootSet = New BusinessEntity.BootSet

        oHead.iHeadID = 1
        oHeadSet.Add(oHead)
        oShell.iShellID = 1
        oShellSet.Add(oShell)
        oBoot = New BusinessEntity.Boot
     
        oBoot.iBootID = 1

        oBoot.iVesselID = 30

        oBootSet.Add(oBoot)
        Return oBootSet
    End Function
&lt;/pre&gt;&lt;br /&gt;
What is in the returned oBootSet is not what I expect. &lt;br /&gt;
I have a bootset returned, containing a headset and a shellset.  There are no items in this set, as my watch indicates:&lt;br /&gt;
-		oBootSet	Count = 1	BusinessEntity.BootSet&lt;br /&gt;
-		(0)	{BusinessEntity.Boot}	Object&lt;br /&gt;
-		BusinessEntity.Boot	{BusinessEntity.Boot}	BusinessEntity.Boot&lt;br /&gt;
		_iBootID	1	Integer&lt;br /&gt;
		_iVesselID	30	Integer&lt;br /&gt;
-		_oHeadSet	Count = 1	BusinessEntity.HeadSet&lt;br /&gt;
		(0)	Count = 0	Object&lt;br /&gt;
-		_oShellSet	Count = 1	BusinessEntity.ShellSet&lt;br /&gt;
		(0)	Count = 0	Object&lt;br /&gt;
		iBootID	1	Integer&lt;br /&gt;
		iVesselID	30	Integer&lt;br /&gt;
-		oHeadSet	Count = 1	BusinessEntity.HeadSet&lt;br /&gt;
		(0)	Count = 0	Object&lt;br /&gt;
-		oShellSet	Count = 1	BusinessEntity.ShellSet&lt;br /&gt;
		(0)	Count = 0	Object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What am i doing wrong?Please Help!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/412198/412198/help-with-object-containing--2-other-objects/</guid>
      <pubDate>Fri, 22 Jan 2010 13:56:02 -0700</pubDate>
      <category>.NET General</category>
    </item>
  </channel>
</rss>